ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
To add text to the bottom of a file you would use >> instead of > because the second method overwrites the entire file with the entire contents of the first one.
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
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!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.