< 1 minutes read

Let us try to omit total 2188 from below output in linux. This output is for ls -latr “some path” and this solution is valid for any other command where one would like to omit the first line.

[root@IDIQDEV002 tools]# ls -latr
total 2188
-rw-r--r--   1 root root  689461 Sep 28  2016 setuptools-28.0.0.zip
drwxr-xr-x  15 root root    4096 Sep 28  2016 ansible
drwxr-xr-x   7 root root    4096 Sep 28  2016 setuptools-28.0.0
-rw-r--r--   1 root root 1524722 Sep 28  2016 get-pip.py
dr-xr-x---. 46 root root    4096 Jul 23 03:28 ..
drwxr-xr-x   3 root root    4096 Jul 23 03:31 botpress
drwxr-xr-x   5 root root    4096 Jul 23 03:31 .

Passing actual command’s output to awk or sed using pipe

awk way of doing this

ls -latr | awk 'NR>1'

sed way of doing this

ls -latr | sed '1d'

tail way of doing this

ls -lart | tail -n +2

The -n +2 means “start passing through on the second line of output”.


Simon

I am a Fullstack developer and Consultant with an experience of 9+ years in the industry. I mainly work on Java, React, Javascript, NodeJs, Elasticsearch and Botpress.

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.