Script solution as singleline ?

Hello

My script has following line and output

find path -type d | awk -F "/" 'NF == 4{print $3}'
path/custype=Type1/logdate=20160414
path/custype=Type11122/logdate=20160414

But I need following output that I need custtype information between "" like

path/custype="Type1"/logdate=20160414
path/custype="Type11122"/logdate=20160414

There is no constant value length for custtype.
So is there any solution within awk/sed or any command?

Thanks

With that awk script the output cannot possibly be what you posted. I assumed it was the output of the find command without the awk bit...

Try:

sed 's|custype=\([^/]*\)/|custype="\1"=|' 

Hello msuluhan,

Could you please try following and let me know if this helps you, as I don't have your find command's output so I couldn't test it.

find path -type d | awk -vs1="\"" -F "/" 'NF == 4{gsub(/custype=/,"custype=" s1,$0);gsub("/logdate",s1"/logdate",$0);print $3}'

Thanks,
R. Singh

Hello

Thanks for your reply, here is the output

$find 20160415/custstat -type d | awk -vs1="\"" -F "/" 'NF == 4{gsub(/custype=/,"custype=" s1,$0);gsub("/logdate",s1"/logdate",$0);print $3}'
custtype=1234567"
custtype=Type111112"

------------------------------------------------------------------------

Hello Scrutinizer

I tried your advice like following line if I understand correctly

find 20160415/custstat -type d | sed 's|custype=\([^/]*\)/|custype="\1"=|'

sed does not change any output, output like

20160415/custstat
20160415/custstat/custtype=1234567
20160415/custstat/custtype=1234567/logdate=20160415
20160415/custstat/custtype=Type111112
20160415/custstat/custtype=Type111112/logdate=20160415

Thanks

Yes in the original sample it was custype and there was always a trailing slash..

Try this instead..

sed 's|custtype=\([^/]*\)|custtype="\1"|'