Odd Control Character issue ^A


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Odd Control Character issue ^A
# 1  
Old 01-05-2010
Odd Control Character issue ^A

Sorry to bug you, but my sed is failing me,

I have a file auto generated from abinitio, it has a string of chars ending with a line break, and then it has added a ^A character, I can remove this is vi by using the following %s/^A//g (where ^A is ctrl v and control A), however when I try to sed it out of the file so I can script it, it does not work. Working on Redhat.

I am trying to use:
Code:
cat /tmp/$$.tmp|sed -e '%s/^A//g' > /tmp/mynewfile.tmp  this does not work, and leaves me with a file full of

338226285|10022|XXXXXX|67542|111|VI-XX-UK - XXXXXXHOUSE|99|A02999|XXXXX(SALES HSE)|11999|HP BEAR (V)|30|20100101|18|99889|XXX/XXXX001/030|8|XXXX|999|.01|999|.01|1|88999|NEWTEXT|C|3|48999000|S
^A
338226285|10022|XXXXXX|67542|111|VI-XX-UK - XXXXXXHOUSE|99|A02999|XXXXX(SALES HSE)|11999|HP BEAR (V)|30|20100101|18|99889|XXX/XXXX001/030|8|XXXX|999|.01|999|.01|1|88999|NEWTEXT|C|3|48999000|S
^A


I have also tried the following to little success

Code:
cat /tmp/1883.tmp|tr -d "\r" > myfile.tmp
cat /tmp/1883.tmp|sed 's/.^A//g' > /tmp/myfile.tmp
cat /tmp/1883.tmp | tr -d "\r \n" > /tmp/myfile.tmp

Any help much appreciated as it's doing my nut at the moment.
# 2  
Old 01-05-2010
Control-A is ascii 1. I don't understand the sed against '\r \n' thing. If I get what is actually in the file: you have a ^A\n on a line by itself.

Code:
egrep -v '^A' filename > newfile

where ^A is actually ascii 1... Give it a try.

If this is not the case can you show the output of
Code:
head filename | od

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Replace character in odd or even lines

Hello, I'm here again asking for your precious help. I'm writing some code to convert csv files to html. I want to highlight header and also I want to have rows with alternate colors. So far this is my work###Let's format first line only with some color cat $fileIN".tmp1" | sed '1... (7 Replies)
Discussion started by: emare
7 Replies

2. UNIX for Dummies Questions & Answers

Removing the ^M control character

I've got a file where each line is separated by ^M characters. I want to be able to cat the file without those lines. When I cat the file now what I see are blank lines. However, the blank lines are actually ^M characters; when I open the file with vi they show up. X38888 No No No... (7 Replies)
Discussion started by: newbie2010
7 Replies

3. Shell Programming and Scripting

Replace Control M (^M) character with new line

Hi All, We are getting an external file in abc.csv format. When opened in excel spread sheet, it is opening alright. But when opened in notepad, I see the contents in a single line. Ftp'd the file in binary mode to AIX UNIX host. When opened, I see Control M (^M) characters in place of New Line... (16 Replies)
Discussion started by: njny
16 Replies

4. Shell Programming and Scripting

Odd looping issue with NET::FTP and Proftpd

Hello, I'm a UNIX SysAdmin at a large webhosting company and we have a vendor that provides a service which involves the ftp'ing of files from their servers to ours. They initiate FTP using a perl script with NET::FTP. When they try to transfer files (and delete files over ftp), there is... (3 Replies)
Discussion started by: tmmgeekette
3 Replies

5. Red Hat

named caching server odd lookup issue!

Hello All, I have resubmitted this issue I am having as the my last post was moved to programming as the issue appeared to be specific to java but on further investigation this is not the case. The issues also arises when running the host command and appears to be either a problem with the... (1 Reply)
Discussion started by: Paragon1970
1 Replies

6. Shell Programming and Scripting

control M character in unix file

in a file we are getting control character in a file , is there any way that they can be removed once we have the file for eg. BEGIN-PROCEDURE INITIALIZE ^M LET #row_count = 0^M ^M ^M (2 Replies)
Discussion started by: lalitpct
2 Replies

7. Shell Programming and Scripting

Replace any control character in the string

Need to replace any control character in the string in perl ---------- Post updated at 04:22 PM ---------- Previous update was at 03:50 PM ---------- Any help !!! Thanks in advance (2 Replies)
Discussion started by: hansini
2 Replies

8. Shell Programming and Scripting

Removing Control M character

Hi, I'm using MKS tool kit to execute KSH on windows and samba to move files to unix from windows. My script is appending header record for the data file. I'm using echo "$header" > $SambaFilename cat $windowsfile >> $SambaFilename But after execution of script ,The file in Unix... (2 Replies)
Discussion started by: ammu
2 Replies

9. UNIX for Dummies Questions & Answers

odd character (^M) from .sh when chagining to .ksh

// AIX 5.3 I am trying to use .sh after changing it to .ksh Obviously, it doesn't like the file extension change. I am seeing a lot of odd characters (^M) like below: Init_Part2 ()^M^M {^M^M AWTRACE "AW SET"^M^M set | grep -e CFG_ -e OUTDIR_ENV^M^M AWTRACE "AW SET"^M^M ^M^M if ;... (2 Replies)
Discussion started by: Daniel Gate
2 Replies

10. UNIX for Dummies Questions & Answers

Control character in a file

Hi All, I am looking for a solution to capture any ASCII control character in a file ( where the ASCII control character is in decimal value from 0 to 31 and 127 ( Hex value from 00 to 1F and 7F ) ) by returning any affected lines. The intended good file should contain "ASCII printable... (5 Replies)
Discussion started by: cursive
5 Replies
Login or Register to Ask a Question