I'm trying to go through a CSV file (technically a .gz file) and read the second column. Came across this question but am having some difficulty with using the first answer.
Command I'm using is grep ${VALUE} inputfile.csv | cut -d, -f${INDEX}
.
For my shell script, I think it should be grep ${apples} inputfile.csv | cut -d, -f${2}
.
However, I'm getting an error of
cut: option requires an argument -- 'f'
Try 'cut --help' for more information
The comma in the command didn't seem right, so I edited it to
grep ${apples} inputfile.csv | cut -d -f${INDEX}
which gave me an error of
The delimiter must be a single character
Try 'cut --help' for more information
What is the right syntax for grabbing the field after apples? CSV file header looks like this - very simple:
fruits | fruitcount