Question: How do I print the whole text file but skip the first line?
I have a text file cities-population.csv containing city name, state abbreviation and population.
These are the first 10 lines:
$ head -n 10 cities-population.csv
city,state,population
Abbeville,AL,2378
Adamsville,AL,4178
Addison,AL,669
Akron,AL,236
Alabaster,AL,34748
Albertville,AL,23710
Alexander City,AL,14515
Aliceville,AL,2024
Allgood,AL,557
I want to skip the first line containing the header and print the rest of the text file.
Solution 1: Use tail
This command will print the text file except the first line.
tail -n +2 cities-population.csv
The syntax is:
tail -n +<N+1> <filename>
Here, the counting starts with line 2, so we say tail -n +2.
Solution 2: Use awk
If you want to use awk, this works too.
awk 'NR > 1' cities-population.csv
Solution 3: Use sed
If you like sed, run this command.
sed '1,1d' cities-population.csv
Related Posts
If you have any questions, please contact me at arulbOsutkNiqlzziyties@gNqmaizl.bkcom. You can also post questions in our Facebook group. Thank you.