How can I get a part of text file by terminal

Emanuella Ramos Cavalcante

How can I get some block of text by lines?

I have a log file with 6000000 lines and I want get just a block of 607366 to 700000.

I've tried something like:

head -n 607366 | tail -700000 server.log > outputFile.txt
Radu Rădeanu

You can use sed:

sed -n 607366,700000p server.log > outputFile.txt

If you want to use head and tail, this is the right way:

head -n 700000 server.log | tail -n $(echo 700000-607366+1 | bc) > outputFile.txt

or, shorter:

head -n 700000 server.log | tail -n 92635 > outputFile.txt

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

How can I display text from a file automatically after powering up my computer, in text editor or terminal?

분류에서Dev

How can I get the root terminal to add myself into sudoers file so that I can act as root?

분류에서Dev

How can I read a text file from the terminal and save the output to another file in java?

분류에서Dev

How can I delete a fixed part of some lines from a text file?

분류에서Dev

How can I copy a text file into another?

분류에서Dev

How can I get a block cursor in Vim in the Cygwin terminal?

분류에서Dev

How to get text file content to table using awk,sed,grep or cut in linux terminal prompt

분류에서Dev

How can I make readline add pre-"typed" text on terminal startup?

분류에서Dev

How can I get the name of the file I'm uploading

분류에서Dev

how can I read from an uploaded text file

분류에서Dev

How can I run a specific line as a command in a text file?

분류에서Dev

How can I remove text on the last line of a file?

분류에서Dev

How can I extract text before a character or string in a batch file?

분류에서Dev

How can I get the text in the bottom left of my buttons?

분류에서Dev

How can I get the full text of the active window in an SSMS addin?

분류에서Dev

How can I rename a file containing "&" in its name in kubuntu using Dolphin or terminal?

분류에서Dev

How can I change the prompt of the terminal permanently

분류에서Dev

How can I delete files in terminal fluently?

분류에서Dev

How can I delete files in terminal fluently?

분류에서Dev

How can I open a terminal window on OSX?

분류에서Dev

How do I get root in terminal?

분류에서Dev

How can I get the contents of a file one line at a time?

분류에서Dev

How can I get "RHEL 7.0 vmlinux" file?

분류에서Dev

How can I get the extension(s) of a file based on its content?

분류에서Dev

I can't rename a file using the terminal if it came from a parameter

분류에서Dev

Can I recover this corrupted text file

분류에서Dev

Can I get only the part of the string that matches with Grep

분류에서Dev

How can I append an incremental count to every predefined word of a text file?

분류에서Dev

How do I permanently enable terminal output to a file?

Related 관련 기사

  1. 1

    How can I display text from a file automatically after powering up my computer, in text editor or terminal?

  2. 2

    How can I get the root terminal to add myself into sudoers file so that I can act as root?

  3. 3

    How can I read a text file from the terminal and save the output to another file in java?

  4. 4

    How can I delete a fixed part of some lines from a text file?

  5. 5

    How can I copy a text file into another?

  6. 6

    How can I get a block cursor in Vim in the Cygwin terminal?

  7. 7

    How to get text file content to table using awk,sed,grep or cut in linux terminal prompt

  8. 8

    How can I make readline add pre-"typed" text on terminal startup?

  9. 9

    How can I get the name of the file I'm uploading

  10. 10

    how can I read from an uploaded text file

  11. 11

    How can I run a specific line as a command in a text file?

  12. 12

    How can I remove text on the last line of a file?

  13. 13

    How can I extract text before a character or string in a batch file?

  14. 14

    How can I get the text in the bottom left of my buttons?

  15. 15

    How can I get the full text of the active window in an SSMS addin?

  16. 16

    How can I rename a file containing "&" in its name in kubuntu using Dolphin or terminal?

  17. 17

    How can I change the prompt of the terminal permanently

  18. 18

    How can I delete files in terminal fluently?

  19. 19

    How can I delete files in terminal fluently?

  20. 20

    How can I open a terminal window on OSX?

  21. 21

    How do I get root in terminal?

  22. 22

    How can I get the contents of a file one line at a time?

  23. 23

    How can I get "RHEL 7.0 vmlinux" file?

  24. 24

    How can I get the extension(s) of a file based on its content?

  25. 25

    I can't rename a file using the terminal if it came from a parameter

  26. 26

    Can I recover this corrupted text file

  27. 27

    Can I get only the part of the string that matches with Grep

  28. 28

    How can I append an incremental count to every predefined word of a text file?

  29. 29

    How do I permanently enable terminal output to a file?

뜨겁다태그

보관