The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-24-2007
rinku rinku is offline
Registered User
  
 

Join Date: May 2007
Posts: 54
Smile 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 07:46 AM.. Reason: Not working
  #2 (permalink)  
Old 05-24-2007
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
Use tr command to remove numeric value from the file
  #3 (permalink)  
Old 05-24-2007
Unbeliever Unbeliever is offline
Registered User
  
 

Join Date: Jul 2005
Location: England
Posts: 183
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 (permalink)  
Old 05-24-2007
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,422
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 (permalink)  
Old 05-24-2007
drl's Avatar
drl drl is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2007
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 699
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 09:27 AM.. Reason: Clarify.
  #6 (permalink)  
Old 05-24-2007
Unbeliever Unbeliever is offline
Registered User
  
 

Join Date: Jul 2005
Location: England
Posts: 183
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 (permalink)  
Old 05-24-2007
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,422
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.
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 05:26 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0