How to append a string at end of a specific line in a file in bash [duplicate]

Using sed and the pattern described:

sed '/192.168.1.2/s/$/ myalias/' file

Using sed and a specific line number:

sed '2s/$/ myalias/' file

Leave a Comment