I have a very long file which I want to print but skipping the first 1e6 lines for example. I look into the cat man page but I did not see any option to do this. I am looking for a command to do this or a simple bash program.
相关问题
- Is shmid returned by shmget() unique across proces
- how to get running process information in java?
- JQ: Select when attribute value exists in a bash a
- Error building gcc 4.8.3 from source: libstdc++.so
- Why should we check WIFEXITED after wait in order
Easiest way I found to remove the first ten lines of a file:
Just to propose a
sed
alternative. :) To skip first one million lines, try|sed '1,1000000d'
.Example:
A less verbose version with AWK:
But I would recommend using integer numbers.
I needed to do the same and found this thread.
I tried "tail -n +, but it just printed everything.
The more +lines worked nicely on the prompt, but it turned out it behaved totally different when run in headless mode (cronjob).
I finally wrote this myself:
If you have GNU tail available on your system, you can do the following:
It's the
+
character that does what you want. To quote from the man page:Thus, as noted in the comment, putting +1000001 starts printing with the first item after the first 1,000,000 lines.
You'll need tail. Some examples:
If you really need to SKIP a particular number of "first" lines, use
That is, if you want to skip N lines, you start printing line N+1. Example:
If you want to just see the last so many lines, omit the "+":