Visit Our UNIX and Linux User Community

How to erase junk Chars coming in only the first line

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to erase junk Chars coming in only the first line
# 1  
Old 11-01-2011
How to erase junk Chars coming in only the first line

I have a file containing few thousands of lines. when I do cat on it , i find it having two special Chars at the start of first line alone as shown down here.


If i delete this line and do a cat on file , the current first line is shown to have the same special Chars.


And For clarity of understanding the Issue , the file is indicating to have been converted and saved when :w command issued in there.

"EDW.VOC.BK.FEED.SEQ01.POS.txt" [converted] 113682L, 7194355C

I want to know how to get rid of the special chars and whether the issue is due to file not being converted properly as it was Ftped from Windows before being converted using :set ff=unix.

Please help me with getting over it.


Moderator's Comments:
Mod Comment Video tutorial on how to use code tags in The UNIX and Linux Forums.

Last edited by radoulov; 11-01-2011 at 06:32 AM..
# 2  
Old 11-01-2011
Can you attach a file with an example? With only one row?
# 3  
Old 11-01-2011
What are the actual characters? (od -x -N32 infile)
# 4  
Old 11-02-2011
sample file is attached with one line that is having special chars at the bginning when Cat is done on it in unix.

Previous Thread | Next Thread
Test Your Knowledge in Computers #509
Difficulty: Medium
Most programming languages allow you to use whitespace characters (space, tab, etc.) in a variable's identifier.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Grep with special chars line by line

I have a file that includes strings with special characters, eg file1 line: 1 - special 1 line: = 4 line; -3 etc How can I grep the lines of file1 from file2, line by line? I used fgrep and egrep to grep a particular line and worked fine, but when I used: cat file1|while read line;do... (2 Replies)
Discussion started by: FelipeAd
2 Replies

2. UNIX for Dummies Questions & Answers

Erase line of text file one by one

Hi, I have a BASH script where I would like to identify all the lines of a text file that match specific pattern, and then erase them one by one. The ultimate goal will be to identify all the lines matching the pattern, and then for each line identified prompt the user whether or not to erase... (3 Replies)
Discussion started by: msb65
3 Replies

3. Shell Programming and Scripting

How To Erase a line is a row is empty?

Hi! i've been reading you guys for some time, now there is something I couldn't find here, I'm trying to purge some data for my thesis but my measurements have some gaps in the third columns. The solution is simple, -Erase those lines where the third column is empty ┐How? example... (1 Reply)
Discussion started by: AriasFco
1 Replies

4. UNIX for Advanced & Expert Users

junk characters in the begining of every line

Hi Experts, here is a background to my problem : I am exporting data from teradata using fastexport utility, as varchar data. This pads additional two bytes (2 places as seen in notepad) in the resultset. I have found out other means of avoiding it but can't use varchar option in that... (5 Replies)
Discussion started by: sumoka
5 Replies

5. Shell Programming and Scripting

Junk Character appended at the end of a line

Hi All I have a rather unusual problem, which i have not faced till now. I have a script which exports some paths to a text file. The script runs fine but when i check the output file i can see some junk characters ^M appended at end of lines and random places. I am not able to figure... (4 Replies)
Discussion started by: raghu_shekar
4 Replies

6. Shell Programming and Scripting

Output coming in different line instead of single line

Hi Guys, I have an oracle database, I am trying to query the database and route it to file. But the records instead of coming in a single line, are coming in three lines. Can you please help me.. in this.. sqlplus -s $SRMUserid/$SRMPassword@$SRMServer<< EOF >log.out; select * from... (5 Replies)
Discussion started by: mac4rfree
5 Replies

7. Shell Programming and Scripting

find 4 chars on 2nd line, 44 chars over

I know this should be simple, but I've been manning sed awk grep and find and am stupidly stumped :( I'm trying to use sed (or awk, find, etc) to find 4 characters on the second line of a file.txt 44-47 characters in. I can find lots of sed things for lines, but not characters. (4 Replies)
Discussion started by: unclecameron
4 Replies

8. Shell Programming and Scripting

is is possible remove junk chars from the strings?

Hello friendz, dfl;g435hkd.fg ..this is what I am getting. I want to print strings without junk chars. I want to exactly like this... dflg435hkd.fg ...need some specific operators also. for example, dot or comma should allow. plz help me out ya! ~Balan:confused: (1 Reply)
Discussion started by: balan_mca
1 Replies

9. Shell Programming and Scripting

How to erase files with line number less than 100

I am trying to delete all the files with line number less than 100 in a directory. Thank you. (5 Replies)
Discussion started by: Sean2008
5 Replies

10. Shell Programming and Scripting

Replace Junk chars (Sed)

I know this has been asked previously on this forum...But I think I have a different scenario to present. I ahve a file tht looks like this (note:there are control Z and other chars tht are not visible on line with anme bowers) BB7118450 6004718 BIANCALANA =HEI BZ5842819 ... (4 Replies)
Discussion started by: alfredo123
4 Replies

Featured Tech Videos