Direkt zum Inhalt
Ville-Pekka

Hauptnavigation

  • Startseite

Pfadnavigation

  1. Startseite

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

Von ville , 8. Dezember 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
  • Anmelden, um Kommentare verfassen zu können

Kommentare

Language switcher

  • English
  • Deutsch
  • Suomi
RSS-Feed
Unterstützt von Drupal