get all line except n last one
with head -n <negative number> we can get the output except n lines
example
1
cat a.txt | head -n -1
Copied!
will gives as the content of a.txt except the last one
Let say we have file 1 2 3 4 5, and with grep we want to only get 1 2 3.
we can achive this with ls and grep
1
$ ls | grep 4 -B 100000000 | head -n -1
Copied!
the -B show 100000000 lines before matched line, and the head -n -1 removes the matched
Last modified 1mo ago
Copy link