Hi guys,
Can u please help me to replace (-) with (/) in a file containing no of records using "sed " command in unix.
thanks in advance.
subhendu
Hi guys,
Can u please help me to replace (-) with (/) in a file containing no of records using "sed " command in unix.
thanks in advance.
subhendu
I"m not as good as some of the guys here but try this
sed 's/-/\//' filename > newfile
Try also with tr ,perl and awk:
[/tshome/tf01 ]>x="ashdkhsa-sdasldhals-sadakjsh-"
[/tshome/tf01 ]>echo $x | tr "-" "/"
ashdkhsa/sdasldhals/sadakjsh/
or,
perl -ne 's/-/\//;print;' filename
or,
[/tshome/tf01 ]>echo $x | awk '{gsub(/-/,"/",$0); print; }'
ashdkhsa/sdasldhals/sadakjsh/
hi guys,
how can i convert multiple spaces to single space using sed in unix.
thanks in advance.
subhendu
how many spaces are you talking about?
you can use any one of the methods above.
I would try this:
sed 's/ / /' filename
in addition, read through sed manual
man sed
they have lots of information and examples.
Is this a homework or sth?
try this,
tr -s " " < filename > outfile