[KLUG Members] help with bash script error

Bruce Smith bruce at armintl.com
Mon Sep 12 21:13:06 EDT 2005


>         Subject: Re: [KLUG Members] help with bash script error
>         > Thanks everyone, but I got it. I opened the file in ee
>         instead of vi and 
>         > I saw all these ^M at the end of each line. I took them out
>         and
>         > viola...things work. I wonder what I would need to do to get
>         vi to print
>         > these.
>         
>         You can get rid of them in vi with
>         
>           :set fileformat=unix 
>         
>         and check the file format (dos/unix) with
>         
>           :set all
>         
>         - BS
> 
> The ^M's are the MSDOS newline character, if I remember right.  

It's a carriage-return (CR).  MSDOS uses a CR _and_ a LF  (line feed)
both to terminate a line.  Linux/Unix only uses the LF (aka newline).

> You can also use the dos2unix command to convert the file to unix
> format after you've saved it.  

Yup.

> If you've got some massively long file, it might be faster than
> manually going through and deleting every single instance of ^M.  

He said he was using vi.  Simply changing the fileformat inside of vi
and saving the file also gets rid of the CR (as I said above).

 - BS




More information about the Members mailing list