Removing Special Character from File.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Removing Special Character from File.
# 1  
Old 08-27-2010
Removing Special Character from File.

Hi,

My file has this special character "^M"

I would like to remove this characters.

eg:

abc,abc,^M

i tried using sed but doesnt work.

i used octal dump command to see special character it returns following:
015
\r

Appreciate your reply.
# 2  
Old 08-27-2010
Use "dos2unix" on that file.
# 3  
Old 08-27-2010
Quote:
Originally Posted by bartus11
Use "dos2unix" on that file.
Tried:
Code:
$ dos2unix file

ksh: dos2unix: not found


Also Tried:
Code:
sed 's/^M//g' file> file1

The file1 still has the special character ^M

Appreciate reply
# 4  
Old 08-27-2010
Code:
tr -d '\015' <file >new
mv new file

# 5  
Old 08-28-2010
there are lot of other ways possible...

sed, awk, tr, vim ....


Deleting dos chars using Vim (^M) The eternal fight between admins and computers
^M and vim
# 6  
Old 08-28-2010
try

Code:
sed 's/\^M//g' file1

# 7  
Old 08-30-2010
Quote:
Originally Posted by kurumi
Code:
tr -d '\015' <file >new
mv new file


Thanks this one worked.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Removing special chars from file and maintain field separator

Running SunOs 5.6. Solaris. I've been able to remove all special characters from a fixed length file which appear in the first column but as a result all subsequent columns have shifted to the left by the amount of characters deleted. It is a space separated file. Line 1 in input file is... (6 Replies)
Discussion started by: iffy290
6 Replies

2. Linux

File conversion and removing special characters from a file in Linux

I have a .CSV file when I check for the special characters in the file using the command cat -vet filename.csv, i get very lengthy lines with "^@", "^I^@" and "^@^M" characters in between each alphabet in all of the records. Using the code below file filename.csv I get the output as I have a... (2 Replies)
Discussion started by: dhruuv369
2 Replies

3. Red Hat

Special character ^@ in CSV file

All, I am having a tough time with Linux and CSV file. My CSV file gets generated from Cognos on Linux machine that contains special characters. At first instance when I do vi <filename> to that file, I can't see anything. I did tail -2 and redirected to another temp file and did vi <filename>,... (2 Replies)
Discussion started by: donadarsh
2 Replies

4. Shell Programming and Scripting

parse a file for a special character

hello, How to parse a file to see if a specific line is commented by '#' character? filename: file1 cat file1 ... # /usr/bin/whatever ... thank you (9 Replies)
Discussion started by: melanie_pfefer
9 Replies

5. Shell Programming and Scripting

Removing special characters in file

I have file special.txt with the following data. <header info> 123$ty5%98&0asd 1@356fgbv78 09*&^5jkns43( ...........some more rows. In my output file, I want to eliminate all the special characters in my file and I want all other data. need some help. (6 Replies)
Discussion started by: srivsn
6 Replies

6. UNIX for Dummies Questions & Answers

Special character in my file

I have a special character in my file. It displays as a '#' sign but when I do this command I do not find the line. fgrep 'G#ant' file1 I want to replace the special character with another value but I need to know what character it really is. Any ideas on how to replace this '#' value with... (3 Replies)
Discussion started by: Ryan2786
3 Replies

7. Shell Programming and Scripting

delete a special character in file

hi i want to delete a particular character in file. example file name:abcsample abc=bbbqw3/ hidh=ajjqiwio4/ xyx=hakjp/ ........../ ......./ i want to delete that special character (/) in abcsample file Permnently.please give the required commands for my requirement. required... (1 Reply)
Discussion started by: srivsn
1 Replies

8. Shell Programming and Scripting

delete a special character in file

hi i want to delete a particular character in file. example file name:abcsample abc=bbbqw3/ hidh=ajjqiwio4/ xyx=hakjp/ ........../ ......./ i want to delete that special character (/) in abcsample file.please give the required commands for my requirement. thank you (3 Replies)
Discussion started by: srivsn
3 Replies

9. Solaris

Mount a character special file

Hi together I have 2 systems, mars and venus. The configuration is the same. Every system has a SDLT. I will now backup the datas from mars on the tapedevice from venus. I have shareed the tapedevice (venus) and mounted on mars. Now my problem: when I write on the mountet tapedevice, the... (1 Reply)
Discussion started by: MuellerUrs
1 Replies
Login or Register to Ask a Question