Tuesday, April 30, 2024
10
rated 0 times [  10] [ 0]  / answers: 1 / hits: 54211  / 1 Year ago, wed, february 22, 2023, 6:28:39

I am using the unix pr command to combine multiple text files into one text file:



pr -F *files > newfile


Each file is a different length, a different number of lines. I am mostly happy with the result, I like that it includes the name of the original text file followed by the contents of that file. However, I would like to eliminate the blank lines in between the name of the original text file and it's contents. I only want blank lines between the different text files to separate each. Also, it prints the character ^L after the contents of each text file, and I would like to eliminate that character.



Each file read in is also given a 'page' number. Only one file is longer than the 66 line default. that file ends up being spit into 2 'pages', and is split into 2 sections divided by blank lines. Is it possible to write that text in continuously without it being split?



Thank you for any help!


More From » command-line

 Answers
2

You can use the AWK utility:



awk 'FNR==1{print ""}{print}' *files > newfile


Source: https://stackoverflow.com/questions/1653063/how-do-i-include-a-blank-line-between-files-im-concatenating-with-cat


[#30362] Thursday, February 23, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
weamp

Total Points: 197
Total Questions: 115
Total Answers: 92

Location: Mauritania
Member since Sun, May 7, 2023
1 Year ago
;