awk 2 delimiter nested

Hello All, This work could be very easy for you guys. I would really appreciate help.

input file:

output file: (Desired)

What I am capable of doing:
Command: cat inputfile | awk -F\| '{print "num="$1" value="$2" digits="$3" name1="$4" file="$5" code="$6}' > outputfile

Result what I am capable of getting:

As per my understanding some tricks to that command is needed to involve nested 2 delimiters (i.e. "|" & "," & " "(space) chracter). I dont have any idea how to go about it. Could anyone solve this thing for me or give me some diff logic to acheive this desired output file.

I would really appreciate if some one helps as soon as poss. Thanks a lot people. :slight_smile:

With a modern awk (nawk, gawk, etc), FS (field separator) can be any regular expression.
including a backslash. For example

      FS = "[;:\\\\\\\\]" 

includes:

       ";"   ":"  "\\"  

(The brackets "[" and "]" are part of the regular expression syntax)

I knw that. I myself have used "|" as delimiter. My problem here is to use 2 delimiters in order to get desired output file.

I need outputfile from inputfile by some trick.

Thanks for replying.:slight_smile:

Hi,
Please try this one. On my pc it is ok.

awk 'BEGIN{FS="|"}
{
printf("num=%s value=%s digits=%s ",$1,$2,$3)
n=split($4,arr," ");
for (i=1;i<=n;i++)
{
	split(arr,brr,",")
	printf("name%d=%s:link%d=%s ",i,brr[1],i,brr[2])
}
split($5,crr,",")
printf("file=%s:link=%s ",crr[1],crr[2])
split($6,drr,",")
printf("code=%s:link=%s\n",drr[1],drr[2])
}' a

thank u v much. It works. I appreciate ur efforts.

This is a lengthy one but easy!!!!!!!!!!!!!!!

awk -F"|" '{print "num="$1" value="$2" digits="$3" name1="$4" file="$5" code="$6""}' bb |awk -F"," '{print ""$1" link1="$2" link2="$3" link3="$4" link4="$5""}' |awk -F" " '{print ""$1" "$2" "$3" "$4" "$5" name2="$6" "$7" "$8" "$9" "$10" "$11""}'\^J| sed '2s/line4=//' |sed '2s/name2=//'

Regards,
aajan