Hello Guys
I have a multiple character delimited flat file "|~|". when I tried to read the data the "|" character also coming
Example
I/P file
9882590|~|20111207|~|K03501000063005574033961|~|K|~|
Command to get the second column I used
awk -F"|~|" ' {print $2}' ff_CGS_0005_CGS300.dat
The result I am having
|20111207|
Can you please correct me to get the value without the pipe character
Thnx a lot!
perl -F"\|~\|" -lane 'print "$F[1]"' ff_CGS_0005_CGS300.dat
ni2
3
Hi,
You could also use
$echo "9882590|~|20111207|~|K03501000063005574033961|~|K|~|" | awk -v FS="|" '{print $3}'
20111207
Or you could change |~| to | then pass on to awk.
$echo "9882590|~|20111207|~|K03501000063005574033961|~|K|~|" | sed 's/|~|/|/g' | awk -v FS="|" '{print $2}'
20111207
After more searching.
$echo "9882590|~|20111207|~|K03501000063005574033961|~|K|~|" | awk -v FS="[|~]+" '{print $2}'
20111207