Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Sed script trimming last line
Name: guruprasadv Date: March 22, 2005 at 18:11:54 Pacific OS: Solaris CPU/Ram: 512
Comment:
Hi,
I am going a global replace using the below script.My problem is the last line of the property file is getting deleted.Please any idea on this issue
find /export/home/direfor -type f -name '*.properties' -print | while read i do echo "the files that are being read are: " $i sed 's|'$1'|'$2'|g' $i > $i.tmp && mv $i.tmp $i done
Name: gurubit Date: March 23, 2005 at 03:21:19 Pacific
Reply:
It works fine for me. Put the contents file that you are using and also the $1 and the $2 options.
0
Response Number 2
Name: Jim Boothe Date: March 23, 2005 at 07:27:55 Pacific
Reply:
sed will completely ignore the last line of the file if it is does not end with a newline. If this is the case, if you open one of these files with vi, it will issue a warning to this effect.
awk does not ignore these incomplete last lines, so you could use:
Summary: Greetings... I would be very thankful for any insight into this situation: It seems to me as though a text file I've received does not have a new line character at the end of it. The file is called 1...
Summary: how any one can write SED script for following requirement? Test1.text file has following data : Che is CLA and XP is //event[tag = cast and line = 29] Che is CLA and XP is //event[tag = cast and line...
Summary: Shell commands can append to a file, but that would be AFTER that last newline character. You are wanting to modify the last line, so you need to output a new file, such as: sed '$s/$/:systemuser/' i...