Consider the sample input file
Related posts: awk remove quotes in a column
rajulocal@hogwarts:~/x$ cat input.txt 1.1,k 2.2,ka 3.3,kam 4.4,kama 5.5,kamar 6.6,kamara 7.7,kamaraj 8.8,kamarajuTo put quotes around each line, use the following Perl one liner
rajulocal@hogwarts:~/x$ perl -lane '$sq="\047"; print "$sq$_$sq";' input.txt '1.1,k' '2.2,ka' '3.3,kam' '4.4,kama' '5.5,kamar' '6.6,kamara' '7.7,kamaraj' '8.8,kamaraju'Here we are using octal code of single quote. To put quotes around just one column, use
rajulocal@hogwarts:~/x$ perl -F',' -lane '$sq="\047"; print "$F[0],$sq$F[1]$sq";' input.txt 1.1,'k' 2.2,'ka' 3.3,'kam' 4.4,'kama' 5.5,'kamar' 6.6,'kamara' 7.7,'kamaraj' 8.8,'kamaraju'
Related posts: awk remove quotes in a column
No comments:
Post a Comment