Dear Friends,
I have a flat file where last line of it has word D$mhtt
I want to add a space and back slash after it.
Also wanna add -S "J" in the last line.
Following example will make it clear.
I have this in the last line of file
D$mhtt
I want
D$mhtt \
-S "J"
Please help.
Thank you in advance
Anushree
aigles
April 29, 2010, 4:50am
2
A With sed :
sed '${s/$/ \\/;a\
-S "J"
;}' file
Jean-Pierre.
Dear Aigles,
I have this in the last line of file
D$mhtt
I want
D$mhtt \
-S "J"
Where as your script returned
D$mhtt
\
-S "J"
Please guide me.
Thank you
aigles
April 29, 2010, 8:58am
4
The command works fine for me.
On my AIX box with KSH :
gssjgu:/g/g00k00/gssjgu/TMP> cat input.txt
abcdefghij
D$mhtt
$ sed '${s/$/ \\/;a\
> -S "J"
> ;}' input.txt
abcdefghij
D$mhtt \
-S "J"
$
On my PC with Cygwin bash, the result is the same.
Are you sure that D$mht is on the last line ?
An empty line at the end of the input file will give the result you got.
Jean-Pierre.
Yes, I think its not the last line of the page. An enter character is present in the last
gaur84
April 30, 2010, 7:26am
6
sed '{
s/D\$mhtt/D\$mhtt \\\
-s \"J\"/g
}' FILENAME