May 20, 2011 #1 vuakhobo Technical User Joined Apr 22, 2004 Messages 41 Location 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?
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?
May 21, 2011 1 #2 feherke Programmer Joined Aug 5, 2002 Messages 9,541 Location RO 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. http://free.rootshell.be/~feherke/ Upvote 0 Downvote
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. http://free.rootshell.be/~feherke/
May 23, 2011 Thread starter #3 vuakhobo Technical User Joined Apr 22, 2004 Messages 41 Location US 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? Upvote 0 Downvote
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?
May 23, 2011 #4 feherke Programmer Joined Aug 5, 2002 Messages 9,541 Location RO Hi Sorry, an issue made its way into the [tt]awk[/tt] code. Code: awk -F '\\|\\|' '{print $1}' test1 Feherke. http://free.rootshell.be/~feherke/ Upvote 0 Downvote
Hi Sorry, an issue made its way into the [tt]awk[/tt] code. Code: awk -F '\\|\\|' '{print $1}' test1 Feherke. http://free.rootshell.be/~feherke/
May 24, 2011 Thread starter #5 vuakhobo Technical User Joined Apr 22, 2004 Messages 41 Location US Thank you Feherke, it works great. Upvote 0 Downvote