Insert a character in the beginnig and at the end of each line.

Insert a character in the beginnig and at the end of each line.

Post by Dr » Sat, 03 Apr 2004 12:35:47



Hi guys, im having a problem insering " ' "  at the beginnig and at
the end of each line of a text file containing a list, like...

aaaaaaaaaaa
bbbbbbbbbbb
ccccccccccc
...

the list should be like this..

'aaaaaaaaaa'
'bbbbbbbbbb'
'cccccccccc'
...

Can anyone help me ??
thanks.

 
 
 

Insert a character in the beginnig and at the end of each line.

Post by Chris F.A. Johnso » Sat, 03 Apr 2004 12:47:53



> Hi guys, im having a problem insering " ' "  at the beginnig and at
> the end of each line of a text file containing a list, like...

> aaaaaaaaaaa
> bbbbbbbbbbb
> ccccccccccc
> ...

> the list should be like this..

> 'aaaaaaaaaa'
> 'bbbbbbbbbb'
> 'cccccccccc'
> ...

sed "s/.*/'&'/" FILE

   Or:

awk "{print \"'\" \$0 \"'\"}" FILE

   Or:

while read line
do
  echo "'$line'"
done < FILE

--
    Chris F.A. Johnson                  http://cfaj.freeshell.org/shell
    ===================================================================
    My code (if any) in this post is copyright 2004, Chris F.A. Johnson
    and may be copied under the terms of the GNU General Public License