Consider the input file
This can be achieved in awk by defining both '"' and ',' as delimiters.
keywords: awk remove quotes from string, get rid of quotes, replace the delimiter character
$cat input.txt "k",1.1 "ka",2.2 "kam",3.3 "kama",4.4 "kamar",5.5 "kamara",6.6 "kamaraj",7.7 "kamaraju",8.8Convert this to
$cat output.txt k|1.1 ka|2.2 kam|3.3 kama|4.4 kamar|5.5 kamara|6.6 kamaraj|7.7 kamaraju|8.8i.e. remove the quotes in the first column, change the delimiter to '|'.
This can be achieved in awk by defining both '"' and ',' as delimiters.
$cat cmd.sh cat input.txt | awk -F "[\",]" -v OFS="|" '{print $2,$4}'Execute the above script as
$./cmd.sh > output.txtTested on Debian Wheezy using GNU awk 4.0.1 version.
keywords: awk remove quotes from string, get rid of quotes, replace the delimiter character
No comments:
Post a Comment