I have a file which contains 1 million records of the following format. Each field is delimited by a pipe tilda pipe "|~|" show below. I would like to print only one column ie the CARDDESC value.
for example here it says CARDDESC=A8T1.
so anything after CARDDESC= and before |~|CARDTYPE is what I would like to get from this record and ignore everything else.
In other words the value between CARDDESC= and |~|CARDTYPE which in the following example is A8T1 is what I need to know.
Any help is really appreciated. if my question is not clear please let me know I will try to phrase it in a better way.
Each filed is delimited by |~| that is for sure through out the file. so even if I can get CARDDESC=A8T1 I am happy.
Works for me on Linux (I guess gawk, or actually mawk). matrixmadhan's solution is closer to the real McCoy so use that if it works for you.
Or even, how about this.
sed -n 's/.*|~|CARDDESC=//; T; s/|~|.*//p'
matrixmadhan: agreed, I've seen much worse than this. I can also swear a lot louder than you have seen so far. (My colleagues can tell when I'm forced to use Windows.)
sometimes, delimiters need to be unique so that it won't get mixed up with actual data in the fields. therefore, you shouldn't jump to conclusions like this