unix - Sed to replace first forward slash in line after match with a string -


so have following in file:

/icon.png /my/path/tester/icon.png /logo.png /my/path/tester/logo.png 

i want replace lines not contain 'tester' , add '/my/path/tester/' beginning... leaving:

/my/path/tester/icon.png /my/path/tester/icon.png /my/path/tester/logo.png /my/path/tester/logo.png 

i prefer edit file in place using sed.

thanks in advance!

if have sed supports -i option (eg, gnu-sed):

sed -i '/tester/!s@^@/my/path/tester@' file 

note ask for, not robust. want limit replacement lines not match '/tester/' rather 'tester', , there no point -i option (see sed edit file in place). using -i obfuscates temporary file, reason people not want , think avoid using -i.


Comments

Popular posts from this blog

vb.net - Alternative to the T-SQL AS keyword -

php - MySQLi binding parameters in a prepared statement doesn't work unless inserted after "WHERE" -

ios - CFRelease causing crash in iPad application -