LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-13-2009, 03:21 AM   #1
jcky
Member
 
Registered: Feb 2008
Location: China-Shanghai
Distribution: Rhel&Suse
Posts: 82

Rep: Reputation: 15
A question need your kind help!


If you want to match only numbers, you might use:
[[:digit:]]

Could you please help me to give an example on how to use [[:digit:]]?

Thanks

Br.
 
Old 11-13-2009, 03:37 AM   #2
centosboy
Senior Member
 
Registered: May 2009
Location: london
Distribution: centos5
Posts: 1,137

Rep: Reputation: 116Reputation: 116
Quote:
Originally Posted by jcky View Post
If you want to match only numbers, you might use:
[[:digit:]]

Could you please help me to give an example on how to use [[:digit:]]?

Thanks

Br.
Code:
cat count
test 1
test 5
test 9
test 13
test 17
test 21
test 25
test 29
test 33
test 37
test 41
test 45
test 49
test 53
test 57
test 61
test 65
test 69
test 73
test 77
test 81
test 85
test 89
test 93
test 97

then, remove digits (substitute with nothing)

Code:
cat count | sed 's/[[:digit:]]//g'
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
 
Old 11-13-2009, 05:39 AM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by jcky View Post
If you want to match only numbers, you might use:
[[:digit:]]

Could you please help me to give an example on how to use [[:digit:]]?

Thanks

Br.
Where did you find this?

This is what is generally called a "regular expression" (AKA regex)---which I think can be defined as a string of characters used to designate classes or types of data as opposed to specific data. Examples:

"." = any character
"*" = any number of the preceding regex
thus:
".*" = any number of characters

regexes are used in a wide variety of utilities--eg SED, AWK, GREP--and in programming languages such as PERL.

[ ] defines a "character class", and [:digit:] is a character type
[[:digit:][:blank:]] = a single number or a white space

Good tutorial here:
http://www.grymoire.com/Unix/

Last edited by pixellany; 11-13-2009 at 05:42 AM.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
The kind of question noone thinks anyone will ask davidguygc Linux - Newbie 4 03-08-2007 09:39 PM
A musical kind of question.... randon Linux - General 3 10-14-2003 09:37 PM
What kind of question should i ask...? Tarts LQ Suggestions & Feedback 4 08-12-2003 04:03 AM
kind of an internet question.. Zerodark Linux - General 1 06-21-2003 05:23 PM
A different kind of cron question eastj1974 Linux - General 3 05-28-2003 01:16 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:11 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration