User Tools

Site Tools


guides:software:files

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
guides:software:files [2021/01/04 15:10] wikiadminguides:software:files [2022/08/02 11:59] (current) – external edit 127.0.0.1
Line 3: Line 3:
 There is a difference in how files are stored on these two operating systems. There is a difference in how files are stored on these two operating systems.
  
-By default, when files are created on a windows system, the end of the file is marked with a **ctrl-r** and a **ctrl-n**.  The user does not insert thisit is done automatically by the software.  This is not the case in the linux/unix environment.  The end of line in linux is marked only by the **ctrl-n**.  When performing text processing, the **ctrl-r** will cause problems in the linux environment.+By default, when files are created on a windows system, the end of each line is marked with a carriage return (\r)  and a newline (\n).  The user does not insert thisit is done automatically by the software.  This is not the case in the linux/unix environment.  The end of line in linux is marked only by the newline (\n).  When performing text processing, the carriage return (\rwill cause problems in the linux environment.
  
-===== Checking for **CTRL-R** on Linux ===== +In additionmost files in linux contain a final new line marker.  This is not the case in windows 
-To see if your file contains **ctrl-r** use the linux command ''od''  Od stands for Octal Dump and will display the contents of the file in various formats.  In this caseyou should run ''od -c //filename//''.  This will display each character in the file, with some special characters, like **ctrl-r** and **ctrl-n** proceeded by a slash.+
  
-In this example, the file foo.cpp has been created on a computer running windows and transferred to a computer running linux.  To check the format, the user runs ''od -c foo.cpp'' Note that each line ends in \r and \n+These differences can cause problems when processing files.   
 + 
 +===== Checking for Carriage Return on Linux ===== 
 +To see if your file contains carriage returns (\r) use the linux command ''od''  Od stands for Octal Dump and will display the contents of the file in various formats.  In this case, you should run ''od -c //filename//'' This will display each character in the file, with some special characters, like carriage return and newline proceeded by a slash. 
 + 
 +In this example, the file foo.cpp has been created on a computer running windows and transferred to a computer running linux.  To check the format, the user runs ''od -c foo.cpp'' Note that each line ends in \r and \n.
  
 <code>  <code> 
Line 35: Line 39:
 </code> </code>
  
-In the following example, the file ''bar.cpp'' was produced on a system that did not add **ctrl-r** to the end of each line.+In the following example, the file ''bar.cpp'' was produced on a system that did not add a carriage return (\rto the end of each line.
 <code> <code>
 $ more bar.cpp $ more bar.cpp
Line 47: Line 51:
    return 0;    return 0;
 } }
 +
 $ od -c bar.cpp $ od -c bar.cpp
 0000000   #                     <             e 0000000   #                     <             e
Line 58: Line 63:
  
 </code> </code>
- Note in this example that lines end with a newline (\n).+ Note in this example that lines end with a newline (\n) but not a carriage return (\r). 
 + 
 +===== Converting Files Between Systems ===== 
 + 
 +The utility programs **dos2unix** and **unix2dos** are provided to convert files between the two different operating systems.  The first will remove the carriage return from the and of each line, and the second will add one.  
 + 
 +In this example, the user wishes to convert the file ''foo.cpp'' from dos/windows mode to linux.   
 + 
 +<code> 
 +$ dos2unix foo.cpp 
 +</code> 
  
guides/software/files.1609773035.txt.gz · Last modified: 2022/08/02 11:59 (external edit)