Ask Your Question
1

How can I print all but the first 1000 Lines from a File in Bash?

asked 2023-04-03 22:49:54 +0000

qstack gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-04-03 22:50:32 +0000

qstack gravatar image

updated 2023-04-07 18:20:08 +0000

You can use the tail command in Bash to print all but the first 1000 lines from a file. Here's the command:

tail -n +1001 filename.txt

This will output all lines of the file filename.txt starting from line 1001 and onward, effectively skipping the first 1000 lines.

The -n option specifies the number of lines to display, and the +1001 argument tells tail to start printing from the 1001st line. If you want to save the output to a new file, you can use the output redirection operator > like this:

tail -n +1001 filename.txt > newfile.txt

This will save the output to a new file called newfile.txt in the current directory.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

1 follower

Stats

Asked: 2023-04-03 22:49:54 +0000

Seen: 45 times

Last updated: Apr 07 '23