Home My Accounts | Newsletter | News Flash | Contact Us | Search

 

Issues/Circulation
Current Issue: December 2004
Other Issues
Applications
Matlab Release 14 on Willow
Setting up the MATLAB Environment
Using MATLAB at MCSR, Part II
Dplace Utility
Running CPMD on Sweetgum
Amber 7 on Redwood
Removing ^M From Files
Systems
Redwood Quotas and /ptmp Space
The MCSR Parallel-O-Gram
Removing ^M From Files

Removing Control characters from a file

Quite often when a file is uploaded or “FTPed” it picks control characters at the end of each line. These control characters are “^m” or “controlm”. Once a file is transferred and picked these characters usually at the end of each line it no longer can function as the original file did. That is e.g. if it is a Fortran file it generates many errors and if it is a data file it no longer may be used as an input. Users then need to remove these unwanted control characters. This may be done using the <b>dos2unix</b> utility. From the command prompt, type in:

 

dos2unix oldfile newfile

 

Then the ^m in file "oldfile" will be removed and the clean version saved in file "newfile" under the current directory. In the following file “ctime.f” contains ^m, and file  “ctime_new.f” contains no ^m.

 

willow 2% dos2unix ctime.f ctime_new.f

could not open /dev/kbd to get keyboard type US keyboard assumed

could not get keyboard type US keyboard assumed

willow 3% ls ctime*

ctime.f      ctime_new.f

 

File mf96to2k.f may be used as a test example and may be copied from this path on willow :  /usr/local/appl/examples

 

To avoid having these “^m” in the first place, users should ensure that the correct file transfer mode is used when FTPing or SFTPing their files from one server to another. With command-line file transfer commands, after the command “ftp” or “sftp” is issued to initiate the session, the user should indicate the mode of the transfer by further entering “ascii” for ascii transfer or “bin” for binary transfer. If using the Secure Shell File Transfer program for Windows, users may select the File Transfer Mode from the Operation menu.

 

--------------------------------
Last Modified: Wednesday, 22-Sep-2004 11:04:05 CDT
Copyright © 1997-2005 The Mississippi Center for Supercomputing Research. All Rights Reserved.
[an error occurred while processing this directive]