Skip to main content
Ville-Pekka

Main navigation

  • Home

Breadcrumb

  1. Home

TIL: skip first line of file with "tail -n +2"

By ville , 8 December, 2024

Need for the command occurred when I wanted to skip first line of file as I didn't want to the column descriptions, only the values.

I filtered the company ids by first downloading the csv file from https://www.avoindata.fi/data/fi/dataset/yritykset.

and then executing the command:

head 2024-08-14_full_prh_data.csv  | awk 'BEGIN {FS=";"} {print $2}' | tail -n +2 > yritystunnuksia.txt

head prints first ten lines of file. awk command prints only the second column of each line. Tail -n +2 prints lines starting from second line.

 

Some other options for filtering first line could be found from https://stackoverflow.com/a/71968857/18165446

Tags

  • linux
  • csv
  • awk
  • Log in to post comments

Comments

Language switcher

  • English
  • Deutsch
  • Suomi
RSS feed
Powered by Drupal