Unix/Linux Go Back    



best method of replacing multiple strings in multiple files - sed or awk? most simple preferred :)

UNIX for Dummies Questions & Answers




Kindly Note - This is a Single User Post by Forum Member Scott Regarding:
best method of replacing multiple strings in multiple files - sed or awk? most simple preferred :).
Please Follow The Primary Link Above to View the Full Discussion.

   
Old Unix and Linux 08-26-2010
Scott's Unix or Linux Image
Scott Scott is offline Forum Staff  
Administrator
 
Join Date: Jun 2009
Last Activity: 18 August 2017, 4:31 AM EDT
Location: Zürich
Posts: 8,627
Thanks: 347
Thanked 1,111 Times in 959 Posts
Quote:
Originally Posted by ygemici View Post
also if try want to write last line without \n is return anything


Code:
sed -n "$p" file1

equal null
unfortunately solaris sed has a few bugs LinuxLinux
Hi.

I would (should) expect the same behaviour on AIX as I get on Solaris (but don't have access to it to try now). Perhaps the GNU sed is just too nice to us? Linux

This:

Code:
$ sed -n "$p" file1

is the same as

Code:
$ sed -n "" file1

if p is not set, as $p would be expanded by the shell (as a variable).

Try:

Code:
$ sed -n "$ p" file1

or

Code:
$ sed -n '$p' file1

(although it probably won't print anything on Solaris if there's no newline there!)