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 > 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
Print the first four characters of hostname yxian Shell Programming and Scripting 7 06-15-2009 04:21 PM
awk, ignore first x number of lines. trey85stang Shell Programming and Scripting 8 05-21-2008 04:44 AM
Print the characters in a word chella Shell Programming and Scripting 5 10-17-2007 09:06 AM
to print number one less than actual number cdfd123 Shell Programming and Scripting 4 09-06-2007 06:56 AM
AIX cannot print thai characters ivanwee AIX 0 10-18-2006 03:13 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-03-2007
cdfd123 cdfd123 is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 112
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
  #2 (permalink)  
Old 08-03-2007
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
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
  #3 (permalink)  
Old 08-03-2007
cdfd123 cdfd123 is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 112
Smile

Quote:
Originally Posted by vino View Post
Code:
tr -d '[:alpha:]' < file.txt
Thanks u very much
  #4 (permalink)  
Old 08-03-2007
robotronic's Avatar
robotronic robotronic is offline Forum Advisor  
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
  #5 (permalink)  
Old 08-03-2007
cdfd123 cdfd123 is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 112
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
  #6 (permalink)  
Old 08-03-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,944
Code:
perl -e 'while (<>) { s/[A-Za-z]//g; print }' filename
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 11:43 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
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