Deleting octal values


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Deleting octal values
# 1  
Old 05-27-2011
Deleting octal values

I have some junk values in my files
鵶„‰¼±¤¡ad. am able to find the octal values as below by using od command.
303 251 265 266 204 211 274 261 244 241 141 144

i want to know how to delete the octal this values .
# 2  
Old 05-27-2011
141 and 144 are just lower case letters. But for the other characters, here is a way...

Code:
$
$
$ cat junk
#! /usr/bin/ksh
function myecho
{
        ''echo -e ${1:+"$@"}
        return $?
}
alias echo=myecho
echo hello\\0303\\0251\\0265\\0266\\0204\\0211\\0274\\0261\\0244\\0241there > garbage
od -c garbage
tr -d el < garbage >clean
tr -d \\303\\251\\265\\266\\204\\211\\274\\261\\244\\241 < garbage >clean
od -c clean
exit 0
$
$
$
$ ./junk
0000000   h   e   l   l   o 303 251 265 266 204 211 274 261 244 241   t
0000020   h   e   r   e  \n
0000025
0000000   h   e   l   l   o   t   h   e   r   e  \n
0000013
$
$
$

# 3  
Old 05-28-2011
Thanks

hi ..
i have tried to delete by giving the range in tr command but its not working. lik tr -d '/200'-'/377'.
error is telling characters limit is out of range.

i will try ur response n ll let u know . thank u so much

---------- Post updated at 10:46 PM ---------- Previous update was at 10:43 PM ----------

please help me to give the range . because am not sure whether only this junk values will come .
# 4  
Old 06-14-2011
Hi

Can anyone help on this ???
# 5  
Old 06-14-2011
The -d option to tr takes a string - not a range.

Try the following:
Code:
sed 's/[^[:alpha:][:digit:][:space:][:punct:]]//g'  infile  > outfile


Last edited by fpmurphy; 06-14-2011 at 11:26 AM..
# 6  
Old 06-15-2011
hi

can you please explain ...and also give an example to remove the junk character using sed command.. your help is much appreciated Smilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem with gstat and octal value

Here are a few lines from my script. The problem I am having is that the statement for gstat returns this error: line 43: The statement is coming from gstat. Is there a way to fix it? Apparently -eq 02 is coming up as some octal value, I need it to be recognized as 02. Apparently in... (4 Replies)
Discussion started by: newbie2010
4 Replies

2. Shell Programming and Scripting

Deleting consecutive equal values in a file

Hello everyone, I have a requirement as shown below. I need to delete consecutive same values from the source file and give it as output file. Source: a,b,c,d,e,e,f,g Target: a,b,c,d,f,g The repeating value "e" should be deleted from the file completely. How can I achieve this... (14 Replies)
Discussion started by: vamsikrishna928
14 Replies

3. Shell Programming and Scripting

Deleting values in a column based on conditions

Hi I have a difficulty in writing shell script for performing the tasks. A B C D 12 230 16 259 18 260 23 283 21 291 36 298 41 309 49 420 52 425 57 450 61 456 70 473 72 475 79 486 If the A(row no.2) < C(row no.1) then delete value A(row no.1) and so on... For... (8 Replies)
Discussion started by: Sarwagya Jha
8 Replies

4. Shell Programming and Scripting

Deleting row if all column values are a particular string

Hello, I have a very large file for which I would like to remove all rows for which the value of columns 2-5 is zero. For instance I would like this file: contig1, 0, 0, 0, 0 contig2, 1, 3, 5, 0 contig3, 0, 0, 0, 0 contig4, 0, 5, 6, 7 To become this file: contig2, 1, 3, 5,0 ... (17 Replies)
Discussion started by: mouchkam
17 Replies

5. Shell Programming and Scripting

syntax for IF test or AWK for octal

Using korn shell. I am reading a file line by line. If a record has a carriage return (octal 015) then I append the second record to the first record. Not all records have a carriage return. I have the unix shell script working with grep, but when my file has +100,000 records it runs slow. I would... (3 Replies)
Discussion started by: sboxtops
3 Replies

6. Shell Programming and Scripting

Deleting keys and values-Awk

key pair is 1st and 6th column ex:a20 : p10 or a20 : p11 For every key pair if the vlaue(4th column) is the same then delete all the lines who has keypair and the value ex: a20 : p10 has value 1 only then delete those but a20 : p11 has different values 1,2 and 3 and keep those. input a20 ... (8 Replies)
Discussion started by: ruby_sgp
8 Replies

7. UNIX for Dummies Questions & Answers

ls switch to view octal permissions??

Is there seriously not an easy way to do this? you really need a script for it? that is ridiculous! Please someone tell me there is an ls switch to view octal permissions instead of rwx i want 777. (1 Reply)
Discussion started by: glev2005
1 Replies

8. Shell Programming and Scripting

Deleting values with specific characters

I have a file with 3 columns 2 4 5 2 4 7 3 5 7 4 -6 9 5 -9 4 6 -3 3 Bascially I want to delete the entire row if column 2 is a "-" So the end result will be 2 4 5 2 4 7 3 5 7 I have trouble doing this cause of the - in front of the number. thanks (2 Replies)
Discussion started by: kylle345
2 Replies

9. UNIX for Dummies Questions & Answers

Display permissions in octal format

Hi, Is there any way to display the permissions in octal format rather than "rwxrwxrwx" format. I have a file and i want to see the permissions in octal format. Please help. (11 Replies)
Discussion started by: venkatesht
11 Replies

10. Programming

octal and strings

hi i have a peculiar problem...i have a number of stirngs separated by a '/0'. it looks somethings like: char test="abk\0jsdhj\01234\0" actually i will be reading this from a file or something... im supposed to change the \0 to a ',' but in C the octal representation starts with a '\'...... (1 Reply)
Discussion started by: strider
1 Replies
Login or Register to Ask a Question