cat onelinefile.txt >> newfile.txt; cat twofile.txt >> newfile.txt keep newline?
Ok I have been working on tons of other little problems lately and this one is probably simple to solve. I just can't get my head around it.
I have many one line files and I cat them all to a new file - I keep the new line at the end of each line. For example if I use a simple loop: for i `ls -1` do cat $i >> newfile.txt done where i = a bunch of files that are one line long - I end up with a one line file. if I do this: cat file1 file2 file3 file4 file5 file6 file7 file8 >> newfile.txt I get a file with 8 lines. --- How best can I take an array of file names and pipe the files into a new file? -- |
I'm not sure what could be different, but if I have three one line files (file1, file2, file3 with contents of 'one', 'two' and 'three' respectively) and I do what you describe first, I get a three-line file:
Code:
telemachus $ for item in file* Code:
telemachus $ cat composite |
This works for me :-
for i in `ls -1 | grep -v newfile.txt` do cat $i >> newfile.txt done (I'm assuming you had a typo in your for loop) |
Ok so generally I don't put things in the same location as they start in, but if I do I am path specific about everything...
And as I test things now - neither way works - there is no newline in the single line file? Anyone want to post a quick newline creation sed or awk oneliner? |
Compare the output of these - does the second have double newlines?
Code:
cat filename |
All times are GMT -5. The time now is 11:15 PM. |