Flatten something with loads of lines
This might sound a dumb question and i imagine the answers very basic but how would I turn a file with lots of lines into one file with one line with the same contents.
So I've got a file like this: CUSTOMER name John surname Smith telephone number 379471 age 22 and I would like it like this: name John surname Smith telephone number 379471 age 22 I need to do it in bash On a seperate note is there any way of adding text from one file to another? I've got another customer file id like to add to the end of this one. Thanks a lot, help is much appreciated :) |
python -c "print (''.join(file('filename').readlines())).replace('\n', ' ')" does the first thing
'cat file1 file2 > file1' will do the trick about copying. |
Quote:
cat file.txt >> file1.txt |
Thanks for all the help, I really appreciate it! I should of got the cat thing, spose i just didnt research enough. I'm still having problems putting all values onto one line because i cant use python. Its bash only :(
I'm thinking sed would do it, I just havent worked out how to do it. I can only use bash though :( Thanks everyone |
Quote:
Code:
cat file.txt| tr '\n' ' ' > file1.txt |
Quote:
Code:
[/home/soumen/tmp] $ cat nn Code:
[/home/soumen/tmp] $ my_command |
[also kills the last newline] ... in which case you want this:
$ echo `cat nn | tr '\n' ' '` |
Actually the post was spot on, it did exactly what I wanted and my nasty bit of skoolwork is slowly developing into a fully functional bit of complex code.
Thanks for your help everyone and for super quick responses! |
All times are GMT -5. The time now is 08:03 PM. |