The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
awk, ignore first x number of lines. trey85stang Shell Programming and Scripting 8 05-21-2008 01:44 AM
Print the first four characters of hostname yxian Shell Programming and Scripting 4 10-22-2007 08:54 AM
Print the characters in a word chella Shell Programming and Scripting 5 10-17-2007 06:06 AM
to print number one less than actual number cdfd123 Shell Programming and Scripting 4 09-06-2007 03:56 AM
AIX cannot print thai characters ivanwee AIX 0 10-18-2006 12:13 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 08-03-2007
Registered User
 

Join Date: Jul 2007
Posts: 86
Smile How to ignore characters and print only number using unix?

say
D45H
E67H
G779K
F8888U
T66Y
Y333U

output shud be like
45
67
779
8888
66
333
Reply With Quote
Forum Sponsor
  #2  
Old 08-03-2007
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,683
Quote:
Originally Posted by cdfd123 View Post
say
D45H
E67H
G779K
F8888U
T66Y
Y333U

output shud be like
45
67
779
8888
66
333
Code:
tr -d '[:alpha:]' < file.txt
Reply With Quote
  #3  
Old 08-03-2007
robotronic's Avatar
Can I play with madness?
 

Join Date: Apr 2002
Location: Italy
Posts: 370
Put all the lines in a file (say file.txt) and then:

Code:
sed "s/[^0-9]//g" file.txt

or without file:

echo "D45H" | sed "s/[^0-9]//g"
Bye
Reply With Quote
  #4  
Old 08-03-2007
Registered User
 

Join Date: Jul 2007
Posts: 86
Smile

Quote:
Originally Posted by vino View Post
Code:
tr -d '[:alpha:]' < file.txt
Thanks u very much
Reply With Quote
  #5  
Old 08-03-2007
Registered User
 

Join Date: Jul 2007
Posts: 86
Quote:
Originally Posted by robotronic View Post
Put all the lines in a file (say file.txt) and then:

Code:
sed "s/[^0-9]//g" file.txt

or without file:

echo "D45H" | sed "s/[^0-9]//g"
Bye
Thanks u very much
Reply With Quote
  #6  
Old 08-03-2007
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,609
Code:
perl -e 'while (<>) { s/[A-Za-z]//g; print }' filename
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 02:19 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0