Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
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.
I would like to know which command to use to sustitute a backslash('\') in a file with a forward slash('/'). Also I want to replace all the semi-colons(';') with colons (':').
I guessing that I'm going to have to use the sed command to do this.
I realize that I should be reading the manual to be getting these answers, I plan on doing this but it may take my quite a while, so I'm asking for something I can use right now.
You were right about the man pages. Sed is one of the most useful tools that you have at your disposal, it would really benefit you to learn as much as you can about it. But I too want a quick answer every now and then so here it is:
Code:
sed 's/\\/\//g' <INPUT FILE>
Replaces the slashes. Note that you need to use escape characters in front of those slashed to keep from getting sed confused. The g at the end tells it to replace all instances instead of just the first one it finds.
That works well. It displays the correct output to the screen but does not make changes to the file.
I know this is typical of Linux and also a good thing.
Code:
sed 's/\\/\//g' <INPUT FILE> > <INPUT FILE>
results in an empty file. I guess you can't read and write a file at the same time.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.