Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
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 have a strange sort of question for the brains out there
often when i create text files strange things happen to me
for example, i create a text file under windows, i then transfer it over to my linux system and when i open up the file with vi (using the binary, -b, flag) i have a bunch of margin returns at the end of each line ( ^M ) which many unix programs ignore and the file is thus read as one long line
i usually open the file as such, vi {file} -b
and it shows ^M at the end of everyline
i then go and delete each, which takes way too long
has anybody ever experienced this and if so, are there any shortcuts that i can use (like a find and delete command)?
To convert a file from Windows to Linux style end of lines, then I think the command you want is dos2unix.
Alternatively, there are several Windows text editors that can save with the correct end of line characters, avoiding the problem in the first place. I find Crimson Editor is very good (and free!) http://www.crimsoneditor.com/
(In the "Document" menu, choose "File Format", then "UNIX format").
has anybody ever experienced this and if so, are there any shortcuts that i can use (like a find and delete command)?
Well for linux/unix new line is one character '/n'. For windows new line are two characters /r/n. Return and then new line. I think for Apple the new line is /r and Microsoft combined those two approaches. If you open it without -b option it should be displayed well. I think this is why people say never to edit linux system files in windows. Newbies who cannot use vi if they have a problem with gui and have the tendency to copy system files and alter them in windows. There are many ways delete those character. Some year ago i wrote a lilltle C program to do that, but you may use tr or sed or even trickykid's way ( i don't know, i'm not a vi guru).
But, since you solved the problem, i'll hijack your thread
I always had this problem with vi (not vim, lets say elvis, the standard slackware vi-clone).
when you have a text:
dgfgddg
fgdgdfgfd
gdgdgfgg
how do you delete the new line char. If i want to delete the second line i alway end up to something like this:
dgfgddg
gdgdgfgg
and i don't know how to make it look like this:
dgfgddg
gdgdgfgg
Last edited by perfect_circle; 01-31-2005 at 08:00 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.