Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to parse data with || as delimeter 1

Status
Not open for further replies.

vuakhobo

Technical User
Apr 22, 2004
41
0
0
US
Hello expert,

I have file with || as delimeter
I need help how to parse data with || as delimeter

cat test1|cut -d'||' -f1 <- is not working.
is there a way to get it done?

 
Hi

Complex field separators are better handled by script interpreters :
Code:
awk -F '[i]|[/i]|' '{print $1}' test1

[gray]# or[/gray]

perl -aF'\|\|' -ne 'print $F[0]' test1

[gray]# or[/gray]

ruby -aF'\|\|' -ne 'print $F[0]' test1


Feherke.
 
Thank you for feherke for helping me but I still have problem getting individual value.

I have a test file with contains the content as follow

aaa||bbb||cccddd333||111

when I run

Code:
awk -F '||' '{print $1}' test2.dat

it gave entire string back. How can I get individual value?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top