Re: Backup script runs on AIX but not on Linux

  • From: Tim Gorman <tim@xxxxxxxxx>
  • To: Brandon.Allen@xxxxxxxxxxx
  • Date: Tue, 06 Jan 2009 10:30:04 -0700

The "vi" command "set list" will do the same;  just enter it at the "colon" prompt once you're in "vi".  Then, "set nolist" will turn it off.

To get rid of the "invisible" carriage-return (i.e. "^M") characters, you can use the "vi" command ":s/^V^M//", which translates (in keystrokes) to:
  • char ":" (a.k.a. "colon") to enter "vi" command mode
  • letter "s" (for the "substitute" command in "ex" and "vi")
  • char "/" (a.k.a. "forward slash" for "begin search pattern")
  • CTRL-v
  • CTRL-m
  • char "/" (a.k.a. "forward slash" for "end search pattern, begin replace pattern")
  • char "/" (a.k.a. "forward slash" for "end (empty) replace pattern")
  • then hit <return> (to let 'er rip)

Allen, Brandon wrote:

Yes, that’s normal with vi on Linux – this drove me crazy for an hour or two when I first started working on Linux too.  For some reason the Linux version of vi doesn’t show the DOS characters, but if you look at the bottom line of your vi window it should say [dos] if they are present, like this:



myhost>vi testfile.txt








"testfile.txt" [dos] 5L, 27C          1,1           All



The only way I know of to make it display the characters is with the very cryptic command “:edit ++ff=unix”, e.g.:



myhost>vi testfile.txt

This ^M







:edit ++ff=unix



Also, beware that this problem will occur whether you transfer the file via FTP (in either binary or ascii mode), or SCP.






I ran dos2unix on the script and it fixed it.  Even though I couldn't see any DOS characters, they must have been there somewhere because this fixed the problem. 


Privileged/Confidential Information may be contained in this message or attachments hereto. Please advise immediately if you or your employer do not consent to Internet email for messages of this kind. Opinions, conclusions and other information in this message that do not relate to the official business of this company shall be understood as neither given nor endorsed by it.

Other related posts: