User Tools

Site Tools


remove_special_chars_from_windows_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
Last revisionBoth sides next revision
remove_special_chars_from_windows_files [2017/07/19 14:01] walkeradminremove_special_chars_from_windows_files [2017/07/19 15:26] walkeradmin
Line 8: Line 8:
 \\  \\ 
 \\  \\ 
-dos2unix +Below is a file that I copied from Windows to a CentOS linux server, it dind't matter if I copied the file, or did a copy/paste, the issue still arose. After each line you can see a <color #ed1c24>^M</color> character, which is a Windows carriage return (Linux doesn't use Carriage returns, only line feeds, Windows uses both). 
-vi -b filename+\\  
 +\\  
 +When you edit the file in vi, you can't see these special characters, you have use another switch with vi to show them. Run vi using a <color #ed1c24>-b</color> switch. 
 +\\  
 +    vi -b filename
  
 +----
  
 #!/bin/bash<color #ed1c24>^M</color>\\  #!/bin/bash<color #ed1c24>^M</color>\\ 
Line 31: Line 36:
 gpgcheck=1" > /etc/yum.repos.d/atrpms.repo<color #ed1c24>^M</color>\\  gpgcheck=1" > /etc/yum.repos.d/atrpms.repo<color #ed1c24>^M</color>\\ 
 yum install ffmpeg -y\\  yum install ffmpeg -y\\ 
 +
 +----
 +You can remove these special characters in Linux using a variety of methods, here are two.
 +\\ 
 +    1. In vi, just delete the ^M characters and save the file.
 +    
 +    2. Install dos2unix (yum install dos2unix) and execute this on your file (dos2unix filename) 
 +       and it will remove them for you, handy if it is a big file.
 \\  \\ 
remove_special_chars_from_windows_files.txt · Last modified: 2023/03/09 22:35 by 127.0.0.1