PDA

View Full Version : [SOLVED] Converting Windows to Unix text



fed84
5th August 2015, 05:50 AM
It has been several months since I last used Slackware and vi. I am converting (I think) some files developed while on windows 8.1 to Linux under Fedora 22.
I have no problem in reading the text under gedit or vi but under vi I initially get a screen full of numbered lines describing "something (?)" followed with ^M but upon pressing Enter key the screen shows text lines followed by $.
Under vi the lines all show the $ terminator which I do not recall from my past endeavors with vi. I have tried s/^M//g but the $ remains even after :wq.
Is it the practice of vi to now end all lines with $ ?
What is that first group of numbered lines I get when starting vi and a text file?
Am I not getting the text converted because the output of dos2unix -n shows no difference and I wonder if there is an automatic conversion I am unaware of when using Fedora 22?
Thanks 4 the help!

qubix
5th August 2015, 09:01 AM
can you send us a sample?

vallimar
5th August 2015, 09:48 AM
Google has all the answers:
http://stackoverflow.com/questions/11735560/dollar-sign-at-the-end-of-every-line

fed84
6th August 2015, 06:48 AM
OK on $ terminator unless set nolist.
Still uncomfortable about that mess of numbered lines appearing prior to tapping ENter and whether I should even try to remove them.
Providing example page would require converting page to windows format creating further confusion. Don't have my wifi adapter configured yet for Fedora.

marko
7th August 2015, 01:42 AM
OK on $ terminator unless set nolist.
Still uncomfortable about that mess of numbered lines appearing prior to tapping ENter and whether I should even try to remove them.
Providing example page would require converting page to windows format creating further confusion. Don't have my wifi adapter configured yet for Fedora.

The numbers are a feature in vim, it's just enumerating the lines in the file, if you don't like that
add to the ~/.vimrc file this line:




set nonumber

marko
7th August 2015, 01:49 AM
A tip, frequently I want to check a file for non-printing characters but I don't really want to
do that from vim. What I like to use a lot is :



cat -A filename


cat -A is an shorthand command for "cat -vET" which is :


-v show non-printing characters
-E show end of line character with "$"
-T show tabs

I like to commit software so the file is consistently tabbed or spaced.
Some legacy code files are tabbed so I'd rather leave them that way.
But in many new files I want to make sure tabs don't creep in and
all indenting is spaces.

cat -A is a good way to do that and there's no way it can change the file unlike using vim

rclark
7th August 2015, 01:52 AM
Linux has utilities to handle the job for text files.

dos2unix will hand DOS (windows) to Linux .
unix2dos will handle Linux to DOS.

vallimar
7th August 2015, 05:47 AM
Linux has utilities to handle the job for text files.

dos2unix will hand DOS (windows) to Linux .
unix2dos will handle Linux to DOS.

OP is already aware and neither of those is a resolution to the problem
being discussed. This was an issue with OP being confused over certain
visual elements of VI/VIM.

jpollard
7th August 2015, 07:57 AM
You should have the "dos2unix" utility available for that.

for the converse there is the "unix2dos".

RupertPupkin
7th August 2015, 10:59 PM
HEY VALLIMAR I HEARD DOS2UNIX/UNIX2DOS CAN DO THE TRICK AMIRITE?? :p

vallimar
8th August 2015, 09:21 AM
By golly, I think you've nailed it! Eureka?

fed84
9th August 2015, 11:23 AM
I found that the lines appearing before the "...press enter..." are lines processed in .vimrc.
My examination of that file did not show a correspondence between the line numbers and lines in the .vimrc. Perhaps it is in the systems vimrc in /etc(?).
The dos2unix does work as expected but the file is so noted that it was originally a dos file. OK I knew that just forgot.
@Marko: ONE GREAT IDEA in fact so good I am going to steal it. Thanks!
That cleans this up and I'll find where those lines originate in .(.)vimrc. Thanks to all!