echo '"value1","value2","value3 "," value4","value5"' | awk -vs1="\"" '{gsub(s1,X,$0) gsub(/[[:space:]]/,Y,$0);print}'
Output will be as follows:
value1,value2,value3,value4,value5
2nd:
echo '"value1","value2","value3 "," value4","value5"' | sed 's/\"//g;s/[[:space:]]//g'
Output will be as follows.
value1,value2,value3,value4,value5
Thanks a bunch for the replies. This was very helpful.
I tried the code below and it is working fine for me. I wanted to check if there is a way to ignore the triming of field3. It is a description field and tr command below is causing the values to come as one word. I have given example below:
tr -d '" ' <input_file >output_file
Example:
" value1", "value2","This is a test","value4 "
This tr -d '" ' <input_file is making the out to look like this:
value1,value2,Thisisatest,value4
The description field value is somehow getting as one work the space is gone after the command is run.