Filter special characters


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Filter special characters
# 1  
Old 04-03-2014
Filter special characters

I have a text file that has these special characters.

Code:
^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^E

How would I go about removing them? They come from a c program. I have to use a for loop like this or my outputs gets messed it. I can't use the %s option or my output won't be in the way I need it.

Code:
for(i = 31; i < 80; i++)
            {
                printf(" %c ", line[i]);
            }


Last edited by cokedude; 04-03-2014 at 06:03 AM..
# 2  
Old 04-03-2014
Hello,

Here is an example for same. But if you can provide the input for same so we can give more specific output.

Code:
awk 'gsub(/[[:cntrl:]]/,X,$0) gsub(/[[:punct:]]/,Y,$0) 1'  file_name


Thanks,
R. Singh
# 3  
Old 04-03-2014
Quote:
Originally Posted by RavinderSingh13
Hello,

Here is an example for same. But if you can provide the input for same so we can give more specific output.

Code:
awk 'gsub(/[[:cntrl:]]/,X,$0) gsub(/[[:punct:]]/,Y,$0) 1'  file_name

Thanks,
R. Singh
What input? Do you mean the output file?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Look for substrings with special characters

Hello gurus, I have a lookup table cat tmp1 \\\erw``~ 1 ^774574574565665f\] 2 ()42543^ and I`m trying to compare a bunch of strings such that, either the lookup table column 1, or the string to be looked up are substrings of each other (and return the second lookup column if yes). ... (2 Replies)
Discussion started by: sheetalk
2 Replies

2. Shell Programming and Scripting

Filter last 2 characters of a filename

I have following script to 'archive' some logfiles: for APPHOME in `cat $HOME/archive/apps.cfg` do . $APPHOME/archive/parms.cfg LOGFILES=$(grep "^LOGFILE=" $APPHOME/archive/parms.cfg) for I in $LOGFILES do LOGPATH=$(echo $I |awk -F'=' '{... (2 Replies)
Discussion started by: oliware
2 Replies

3. Shell Programming and Scripting

Replace special characters with Escape characters?

i need to replace the any special characters with escape characters like below. test!=123-> test\!\=123 !@#$%^&*()-= to be replaced by \!\@\#\$\%\^\&\*\(\)\-\= (8 Replies)
Discussion started by: laknar
8 Replies

4. Shell Programming and Scripting

special characters

Hey guys, I'm trying to replace "]Facebook" from the text but sed 's/]Facebook/Johan/g' is not working could you please help me with that? (6 Replies)
Discussion started by: Johanni
6 Replies

5. Shell Programming and Scripting

SED with Special characters

Hello All Seeking the right one SED command. My attempt is: From orginal.txt by SED to target.txt sed -i "/('outbound-callerid/a\$ext->add($context, $exten, '', new ext_SipAddHeader('P-Preferred-Identity', '<sip:${CALLERID(nummer)}@carrier.com>'));" orginal.txtWhat am make wrong?:wall: ... (5 Replies)
Discussion started by: mdbinder
5 Replies

6. UNIX for Dummies Questions & Answers

How to see special characters?

Hi all, I was wondering how can i see the special characters like \t, \n or anything else in a file by using Nano or any other linux command like less, more etc (6 Replies)
Discussion started by: gvj
6 Replies

7. Programming

C++ Special Characters in a String?

Hello. How can i put all of the special characters on my keyboard into a string in c++ ? I tried this but it doesn't work. string characters("~`!@#$%^&*()_-+=|\}]{ How can i accomplish this? Thanks in advance. (1 Reply)
Discussion started by: cbreiny
1 Replies

8. Shell Programming and Scripting

Special characters

When I open a file in vi, I see the following characters: \302\240 Can someone explain what these characters mean. Is it ASCII format? I need to trim those characters from a file. I am doing the following: tr -d '\302\240' ---------- Post updated at 08:35 PM ---------- Previous... (1 Reply)
Discussion started by: sid1982
1 Replies

9. UNIX for Dummies Questions & Answers

how to see special characters in a file using vi

Hi, I have a file which has special characters. I can't see them when I "vi" the file. But I am sure there are some special un seen characters. How can I see them? Please help. Thx (6 Replies)
Discussion started by: jingi1234
6 Replies

10. UNIX for Dummies Questions & Answers

special characters

I have one file which is named ^? ( the DEL character ) I'd like to know how to rename or copy the file by using its i-node number TYIA (2 Replies)
Discussion started by: nawnaw
2 Replies
Login or Register to Ask a Question