On Tuesday 07 September 2004 10:22 pm, Dorward villaruz wrote:
> hi!
>
> try this in commandline i assume you save the file in sams.txt
> final file will be sams2.txt
>
> cat sams.txt | sed -e 's/ /@@/g' -e 's/ //g' -e 's/@@/ /g' > sams2.txt
>
> or put this in a script say convert.sh
>
> script start:
> #!/bin/bash
> cat $1 | sed -e 's/ /@@/g' -e 's/ //g' -e 's/@@/ /g' > $2
> script end:
>
> how to use?
>
> convert.sh <input file> <output file>
>
> best regards,
> wardy
>
Thank you for this. I've spent a few hours today searching and experimenting
to produce this code. I can almost understand the sed command. Everything
between the quotes is the action to be taken. The 's' is for substitution,
the / / is the whitespace to be replaced, the/@@/ is what the whitespace is
replaced with but I don't know what the @@ stands for, the g means it's
applied globally. I think what I just said is wrong because I have no clue
why the second and third substitution are there. And finally the output is
directed to $2. I'll have to wait until tomorrow evening to play with it. I
look forward to it.
thanks,
Jerome