-2

I'm having problems printing just one cell from a .csv file. I was only able to print a single column, but not a single cell.

Here's the command I use to print a column:

BEGIN {FS = ","} {print $1,$3}

And I execute it using:

cat test.csv | awk -f test.awk

My .csv file

I want to manipulate the .csv file by each cell using bash or awk.

Thank you!

jeremybcenteno
  • 119
  • 4
  • 15
  • Your command applies for all lines. If you want to print just the first cell of the first line you have to write NR==1{print $1} – Daniel Apr 29 '16 at 09:24
  • 4
    1) don't attach screenshot, paste some example **TEXT** from your input file(csv) 2) show the expected output – Kent Apr 29 '16 at 09:25

2 Answers2

2

here some simple script. it will out B3 CELL. you can increase head parameter for get cellid.

cat file| awk -v FS=',' '{print $2}'| head -3 | tail -n 1

or

## C2 CELL
cat file| awk -v FS=',' '{print $3}'| head -2 | tail -n 1
aze2201
  • 453
  • 5
  • 12
0

Try this:

 cat a.csv|column -s, -t| cut -d' ' -f<col>|sed '<row>!d'
Ani Menon
  • 27,209
  • 16
  • 105
  • 126