Link to home
Create AccountLog in
Avatar of TIMFOX123
TIMFOX123Flag for United States of America

asked on

Trying to parse CSV in bash!

I have data like this:


bart-d,Red level content search matched,Red,None,/etc/profile,"Solaris 10 - Set Path, umask, and trap in / etc / profile to: umask 022, trap 2 3, and P: / etc export PATH"

if I do a cut -f5 -d","  I get the middle of the last data.

Can simply make a tilde delmited file or somehow tell bash that I want to honor the " , " as a one string instead of two ?

 thank you

I would prefer to do this in bash but I have bash & perl on the boxes  !
Avatar of Tintin
Tintin

Just change the separator to ~ or some other unique character, then you can just do

cut -f5 -d"~"

Open in new window

Avatar of TIMFOX123

ASKER

Excel does not do that very easy.  

I was trying to figure out how to get bash to work with a real csv file

this, that,"the,other,thing",beans,rice
this should be 5 strings, not 7 ;)

ASKER CERTIFIED SOLUTION
Avatar of Tintin
Tintin

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
cool