Search Results

Search: Posts Made By: BrahmaNaiduA
12,888
Posted By RudiC
Try awk -F"|" '{gsub (/\\\|/,"\001");$1=$1;gsub...
Try awk -F"|" '{gsub (/\\\|/,"\001");$1=$1;gsub ("\001", "\\|")}1' OFS="\n" file4
12345678
ABN\|XYZ MED CHEM PTY. LTD.
C

100.00
22
AB"C\|Corp
"XYZ
CDEF"
12,888
Posted By disedorgue
With awk: $ echo $STRING | awk -F'|'...
With awk:
$ echo $STRING | awk -F'|' '{$NF=$NF"\\";X=NF;for(i=1;i<=NF;++i){ $i ~ /\\$/ && --X};print X}'
9

Regards.
12,888
Posted By disedorgue
Hi, for fun, in bash: $ echo $STRING ...
Hi, for fun, in bash:
$ echo $STRING
12345678|ABN\|XYZ MED CHEM PTY. LTD.|C||100.00|22|AB"C\|Corp|"XYZ|CDEF"|
$ X=${STRING//\\|/} && X=${X//[^|]/} && echo ${#X}
9


Regards.
3,161
Posted By Scrutinizer
Try: awk '{if(NR%2-1)gsub(/\|/,"\\|"); else...
Try:
awk '{if(NR%2-1)gsub(/\|/,"\\|"); else if(!NF) $0=RS $0}1' RS=\" ORS= file

There is a single quote at the end of your input, so shouldn't that also be there in your output?...
Showing results 1 to 4 of 4

 
All times are GMT -4. The time now is 02:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy