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 one i will never get there in this life to figure it out , but dor some here it could be a piece of cake because they problably do scrits all day .
Here it is the thing .
by default , to split a text i use tr command like this :
Quote:
tr " " "\n"<infile >outfile
but this command will not work if i have a file like this :
I need tr or any other tool to look into the line , split after first space to a new line , and then look for the splited line , get the other url in another line and etc ....
Is this even possible ?
i know it is , but it will probably a command with 500 letters .
Note that a standard sed uses a backslash followed by a newline in order to print a newline. GNU sed also takes \n for that.
--
Hmm, something is still missing...
Last edited by MadeInGermany; 02-02-2018 at 01:00 PM.
http://fruit apple banana cherry http://colors red blue
http://cars honda toyota http://flavors chocolate vanilla
http://seasons summer fall winter spring
http://fruit
apple banana cherry
http://colors
red blue
http://cars
honda toyota
http://flavors
chocolate vanilla
http://seasons
summer fall winter spring
http://fruit apple banana cherry http://colors red blue
http://cars honda toyota http://flavors chocolate vanilla
http://seasons summer fall winter spring
... this code produced ...
Code:
sed 's/ http/\nhttp/g' $InFile |sed 's/ /\n/' >$OutFile
... produced this OutFile ...
Code:
http://fruit
apple banana cherry
http://colors
red blue
http://cars
honda toyota
http://flavors
chocolate vanilla
http://seasons
summer fall winter spring
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.