What is an efficient BASH one-liner for adding line every 130 characters to a file without lines?

Alain O'Dea

I am trying to process some largish files which lack line separators. I would like to process them with line-oriented tools like grep and sed.

I'd like to put something on the front of my pipeline that will insert a newline every 130 characters. I'm not interested in modifying the input files.

What is an efficient BASH one-liner for adding line every 130 characters to a file without lines?

Leonid Volnitsky

If you really want efficient, there is special command (part of coreutils) for this:

fold -w130 file | ...

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

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

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

remove the first 15 characters from every other line in a file

분류에서Dev

Bash Sed Pipe to Command One-Liner

분류에서Dev

Bash Sed Pipe to Command One-Liner

분류에서Dev

Write first 10 characters of each line to new file using bash

분류에서Dev

Compare every line in file

분류에서Dev

Adding up every 5 lines of integers

분류에서Dev

error reading text file; lines read twice and with every other having extra line break

분류에서Dev

Substitution only on last matching line (perl one-liner)

분류에서Dev

How to read lines of a text file with specific word to an array and get the first four characters of the last line in that array?

분류에서Dev

how to delete the last line in a text file with 100M lines without having to rewrite the whole file?

분류에서Dev

What is the most efficient way to retrieve a line from a file containing multiple sorted runs

분류에서Dev

NodeJS - How to remove the first line of a text file without read all lines?

분류에서Dev

How to Merge Lines from 2 Text File without creating a Line Break in Batch Command

분류에서Dev

Adding line numbers in a file in C

분류에서Dev

How to use Perl one-liner to add line based on first line pattern match?

분류에서Dev

What command(s) will feed a tab-delimited text file and cut each line to 80 characters?

분류에서Dev

One liner variable declaration

분류에서Dev

Conditionally Merging two lines into one line

분류에서Dev

Collapsing a stream of multiple lines into one line

분류에서Dev

Add prefix and suffix to every line in a .txt file

분류에서Dev

Android TextView - Add A New Line After Every 20 Characters

분류에서Dev

Bash - pair each line of file

분류에서Dev

Bash: Path or link to a line in a file?

분류에서Dev

perl one liner + perl line line에서 표준 출력을 제공하는 방법

분류에서Dev

What characters need to be escaped in files without quotes?

분류에서Dev

Adding line breaks to text output file

분류에서Dev

Adding file path as Command Line Argument

분류에서Dev

python iterate through binary file without lines

분류에서Dev

Grep last N characters of each line in a file

Related 관련 기사

  1. 1

    remove the first 15 characters from every other line in a file

  2. 2

    Bash Sed Pipe to Command One-Liner

  3. 3

    Bash Sed Pipe to Command One-Liner

  4. 4

    Write first 10 characters of each line to new file using bash

  5. 5

    Compare every line in file

  6. 6

    Adding up every 5 lines of integers

  7. 7

    error reading text file; lines read twice and with every other having extra line break

  8. 8

    Substitution only on last matching line (perl one-liner)

  9. 9

    How to read lines of a text file with specific word to an array and get the first four characters of the last line in that array?

  10. 10

    how to delete the last line in a text file with 100M lines without having to rewrite the whole file?

  11. 11

    What is the most efficient way to retrieve a line from a file containing multiple sorted runs

  12. 12

    NodeJS - How to remove the first line of a text file without read all lines?

  13. 13

    How to Merge Lines from 2 Text File without creating a Line Break in Batch Command

  14. 14

    Adding line numbers in a file in C

  15. 15

    How to use Perl one-liner to add line based on first line pattern match?

  16. 16

    What command(s) will feed a tab-delimited text file and cut each line to 80 characters?

  17. 17

    One liner variable declaration

  18. 18

    Conditionally Merging two lines into one line

  19. 19

    Collapsing a stream of multiple lines into one line

  20. 20

    Add prefix and suffix to every line in a .txt file

  21. 21

    Android TextView - Add A New Line After Every 20 Characters

  22. 22

    Bash - pair each line of file

  23. 23

    Bash: Path or link to a line in a file?

  24. 24

    perl one liner + perl line line에서 표준 출력을 제공하는 방법

  25. 25

    What characters need to be escaped in files without quotes?

  26. 26

    Adding line breaks to text output file

  27. 27

    Adding file path as Command Line Argument

  28. 28

    python iterate through binary file without lines

  29. 29

    Grep last N characters of each line in a file

뜨겁다태그

보관