Skip to content
Advertisement

Print a column without 1st item of that column

Good night everybody, i want to print a column without printing the 1st item of that column.

I want print the 4th column of this csv file:

ID;Curso;AnoNasc;MediaAcesso;Salario;IndiceSatisfacao
1;Psicologia;1994;18;750;3
2;Psicologia;1992;17;754;4
3;Psicologia;1991;13;780;4
4;Psicologia;1993;11;900;4

So i do this:

system("awk -F ';' '{print $4}' DBcursos.csv > ficha02exer08-mediaacesso.dat");

But this print:

MediaAcesso
18
17
13
11

But i only want the numbers, so i want to print all except the first line (MediaAcesso), how can i do this? Can i do this with AWK?

Thank you!

Advertisement

Answer

Don’t think of it as skipping the first element of a column, you just want to skip processing the entire first row of the file. So check the record number and only process records after that one.

awk -F ';' 'NR > 1 {print $4}' DBcursos.csv > ficha02exer08-mediaacesso.dat
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement