Hello,
Need help substituting a particular word in a file having a single line but no newline character at the end.
I was trying to use sed but it doesn't work probably because there is no newline char at the end of the line.
$ cat hlq_detail
/outputs/alvan23/PDFs/bills
$ cat hlq_detail | sed 's/alvan23/alvan4/g'
The file hlq_detail does not have a newline char after "bills"
Try it with awk:
awk 'sub("alvan23","alvan4")' file
1 Like
Scott
3
Hi.
Out of interest, which OS are you using?
If it's Solaris, try using /usr/xpg4/bin/sed".
Thanks Franklin,
It does work. But, doesn't AWK work in a similar way as SED i.e. it does refer the newline character to check for the end of the line?
---------- Post updated at 03:53 PM ---------- Previous update was at 03:52 PM ----------
I am using HP Unix
kurumi
6
exec 6<"myfile"
while read -r LINE<&6
do
LINE="${LINE/alvan23/alvan4}"
echo "$LINE"
done > tmp
exec 6<&-
mv tmp myfile