help me


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting help me
# 1  
Old 05-24-2007
Bug help me

I want to know how can I write shell programming which remove all numaric value from one file. But that file contain both numaric and string charecter.
after run that script all string charecters are remain as it is. please help me as soon as possible.

tr command is not working. please tell me how can I write that tr command.

Last edited by rinku; 05-24-2007 at 08:46 AM.. Reason: Not working
# 2  
Old 05-24-2007
Use tr command to remove numeric value from the file
# 3  
Old 05-24-2007
Any of these will work
Code:
cat myfile.txt | tr -d 0-9
sed -e 's/[0-9]//g' file.txt
perl -p -e 's/[0-9]//g' file.txt

# 4  
Old 05-24-2007
Quote:
Originally Posted by Unbeliever
Any of these will work
Code:
cat myfile.txt | tr -d 0-9

UUOC
Code:
tr -d 0-9 < file > newfile

# 5  
Old 05-24-2007
Hi, rinku.

What do you consider a "numeric value"? Only characters 0-9? A string like 3.14159? How about -0.707E+1?

The more precise you are, the better the answers. Descriptive titles on your threads will help, too, such as "How to delete numeric values".

Duplicate posts will not endear you to the forum members ... cheers, drl

Last edited by drl; 05-24-2007 at 10:27 AM.. Reason: Clarify.
# 6  
Old 05-24-2007
It is only useless if it has or serves no purpose.

In the past I've found that with new shell users it is easier to explain commands piped together rather than explain redirection. Therefore the purpose is simplicity.

The counter argument is, of course you should give the 'proper' answer the first time. Personal preference I guess.
# 7  
Old 05-24-2007
Quote:
Originally Posted by Unbeliever
It is only useless if it has or serves no purpose.
yup, cat's purpose is to join files, and cat "filename" | <someothercmd> serves no purpose except to waste time "opening" another process
Quote:
In the past I've found that with new shell users it is easier to explain commands piped together rather than explain redirection. Therefore the purpose is simplicity.
<, >> , > and | are all taught as basic shell operations. we use >, >> often to redirect to files.etc.. same with < for input.
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question