I have the following file.txt that follows the same pattern and I want to modify it where this file is by adding an ip:
# gfhfhgfh
gfhfghgfhgfhgfh
MACs
# access
USER CONSOLA *,!10.249.247.3,!10.249.245.65
/bin/false
I want to add an ip in the end of the line that contains as patron USER CONSOLE:
USER CONSOLA *,!10.249.247.4,!10.249.245.65,!10.249.245.90,
I only manage to add the ip in the whole document at the moment but not in that particular line the code used is
sed 's/\r\?$/,!10.10.11.1/' file.txt
sed -i /USER CONSOLA/s/\r/-------/' file.txt
but now inside the text I see all the lines at the end with ^ M – ortiga Jan 19 '19 at 09:52^M
sequence likely indicates that your file has Windows line endings - you can remove them withdos2unix
or see for example How to remove Ctrl-M from files where dos2unix, perl, tr, and sed are not present? – steeldriver Jan 19 '19 at 13:43