GREP TO EXTRACT NON DIGIT FROM EXPRESSION
+7
jeeva
urvershi
Janani
Maithreyi
akalya
mightyganesh
itssrinath
11 posters
GREP TO EXTRACT NON DIGIT FROM EXPRESSION
The file grep.txt contains:
hi
hello
everybody
1987
15
5^
xx.y
HELLO
HI
hi
[335931@oracleclient ~]$ grep [0-9] grep.txt
1987
15
5^
[335931@oracleclient ~]$ grep [^0-9] grep.txt
[335931@oracleclient ~]$
(the second command to extract non digits does nt print anything to the output terminal).Pls help me resolve this.
hi
hello
everybody
1987
15
5^
xx.y
HELLO
HI
hi
[335931@oracleclient ~]$ grep [0-9] grep.txt
1987
15
5^
[335931@oracleclient ~]$ grep [^0-9] grep.txt
[335931@oracleclient ~]$
(the second command to extract non digits does nt print anything to the output terminal).Pls help me resolve this.
itssrinath- Posts : 4
Points : 5
Join date : 2010-02-26
Re: GREP TO EXTRACT NON DIGIT FROM EXPRESSION
hey i am getting output for that ! i dont know how u could not
i got
i got
- Code:
[336474@oracleclient ~]$ cat > grep.txt
hi
hello
everybody
1987
15
5^
xx.y
HELLO
HI
hi
[336474@oracleclient ~]$ cat grep.txt
hi
hello
everybody
1987
15
5^
xx.y
HELLO
HI
hi
[336474@oracleclient ~]$ grep [0-9] grep.txt
1987
15
5^
[336474@oracleclient ~]$ grep [!0-9] grep.txt
1987
15
5^
[336474@oracleclient ~]$ grep [^0-9] grep.txt
hi
hello
everybody
5^
xx.y
HELLO
HI
hi
Re: GREP TO EXTRACT NON DIGIT FROM EXPRESSION
its working here....
[335802@oracleclient ~]$ cat>hi
123
hello
hi
5678
[9]+ Stopped cat > hi
[335802@oracleclient ~]$ grep [0-9] hi
123
5678
[335802@oracleclient ~]$ grep [^0-9] hi
hello
hi
[335802@oracleclient ~]$ grep -v [0-9] hi
hello
hi
[335802@oracleclient ~]$ grep -v [a-z] hi
123
5678
[335802@oracleclient ~]$ grep [^a-z] hi
123
5678
[335802@oracleclient ~]$ cat>hi
123
hello
hi
5678
[9]+ Stopped cat > hi
[335802@oracleclient ~]$ grep [0-9] hi
123
5678
[335802@oracleclient ~]$ grep [^0-9] hi
hello
hi
[335802@oracleclient ~]$ grep -v [0-9] hi
hello
hi
[335802@oracleclient ~]$ grep -v [a-z] hi
123
5678
[335802@oracleclient ~]$ grep [^a-z] hi
123
5678
akalya- Posts : 70
Points : 86
Join date : 2010-03-04
Re: GREP TO EXTRACT NON DIGIT FROM EXPRESSION
grep [0-9] grep.txt
1987
15
5^
[335818@oracleclient ~]$ grep [!0-9] grep.txt
1987
15
5^
[335818@oracleclient ~]$ grep [^0-9] grep.txt
hi
hello
everybody
5^
Its printing!
1987
15
5^
[335818@oracleclient ~]$ grep [!0-9] grep.txt
1987
15
5^
[335818@oracleclient ~]$ grep [^0-9] grep.txt
hi
hello
everybody
5^
Its printing!
Maithreyi- Posts : 76
Points : 142
Join date : 2010-03-03
Age : 36
Location : Haldia
Re: GREP TO EXTRACT NON DIGIT FROM EXPRESSION
i got this ...........
[335765@oracleclient ~]$ grep '[^0-9]' grep.txt
hi
hello
everybody
5^
xx.y
HELLO
HI
hi
[335765@oracleclient ~]$ grep '[^0-9]' grep.txt
hi
hello
everybody
5^
xx.y
HELLO
HI
hi
Janani- Posts : 1
Points : -1
Join date : 2010-02-26
Re: GREP TO EXTRACT NON DIGIT FROM EXPRESSION
use dis it ll work.
grep -v [0-9] grep.txt
grep -v [0-9] grep.txt
urvershi- Posts : 21
Points : 70
Join date : 2010-02-26
Re: GREP TO EXTRACT NON DIGIT FROM EXPRESSION
but i got a doubt now!
in the
in this y am i getting 5^ in the output list???
if it accepts all the words which contain other than [0-9]
(5^ contains ^ which does not fall in [0-9])
what should be my command so as to accept the words which does not have any numbers in them????
in the
- Code:
[336474@oracleclient ~]$ grep [^0-9] grep.txt
hi
hello
everybody
5^
xx.y
HELLO
HI
hi
in this y am i getting 5^ in the output list???
if it accepts all the words which contain other than [0-9]
(5^ contains ^ which does not fall in [0-9])
what should be my command so as to accept the words which does not have any numbers in them????
Re: GREP TO EXTRACT NON DIGIT FROM EXPRESSION
@maithreyi and @ganesh
wat is use of ! in [!a-z] and ^ in [^a-z]??
wat is use of ! in [!a-z] and ^ in [^a-z]??
akalya- Posts : 70
Points : 86
Join date : 2010-03-04
Re: GREP TO EXTRACT NON DIGIT FROM EXPRESSION
@ganesh
try using grep -v [0-9] filename
it'll print only the words
try using grep -v [0-9] filename
it'll print only the words
akalya- Posts : 70
Points : 86
Join date : 2010-03-04
Re: GREP TO EXTRACT NON DIGIT FROM EXPRESSION
cat greptest
hi
hello
everybody
1987
15
5^
xx.y
HELLO
HI
hi
[335814@oracleclient ~]$ grep -v [0-9] greptest.txt
hi
hello
everybody
xx.y
HELLO
HI
hi
[335814@oracleclient ~]$ grep -v [^0-9] greptest.txt
1987
15
in both above cases ^5 is missing....
same way when -v is not used ^5 is present in both
why!!!
hi
hello
everybody
1987
15
5^
xx.y
HELLO
HI
hi
[335814@oracleclient ~]$ grep -v [0-9] greptest.txt
hi
hello
everybody
xx.y
HELLO
HI
hi
[335814@oracleclient ~]$ grep -v [^0-9] greptest.txt
1987
15
in both above cases ^5 is missing....
same way when -v is not used ^5 is present in both
why!!!
Last edited by jeeva on Fri Mar 12, 2010 2:30 pm; edited 3 times in total
jeeva- Posts : 50
Points : 93
Join date : 2010-03-04
Re: GREP TO EXTRACT NON DIGIT FROM EXPRESSION
[^a-z] is negation of[a-z]
[a-z] says accept if it contains any character from a to z
[^a-z] says accept if it contains any other character other than a to z
(it will accept abc123 because it contains 123 which are character other than a to z)
but -v [a-z] says dont accept if it contains any character from a to z
(it will not accept abc123 because it contains abc which are character from a to z ) (i.e. even though it contains 123 it is rejected because it contains abc)
[a-z] says accept if it contains any character from a to z
[^a-z] says accept if it contains any other character other than a to z
(it will accept abc123 because it contains 123 which are character other than a to z)
but -v [a-z] says dont accept if it contains any character from a to z
(it will not accept abc123 because it contains abc which are character from a to z ) (i.e. even though it contains 123 it is rejected because it contains abc)
Re: GREP TO EXTRACT NON DIGIT FROM EXPRESSION
[^a-z] says accept if it contains any other character other than a to z
(it will accept abc123 because it contains 123 which are character other than a to z)
Therefore [^0-9] gives ^5 because it contains character '^' (other than 0-9)
(it will accept abc123 because it contains 123 which are character other than a to z)
Therefore [^0-9] gives ^5 because it contains character '^' (other than 0-9)
Maithreyi- Posts : 76
Points : 142
Join date : 2010-03-03
Age : 36
Location : Haldia
Re: GREP TO EXTRACT NON DIGIT FROM EXPRESSION
Am not able to get output for
grep [^0-9] grep.txt
grep [!0-9] grep.txt
grep [^0-9] grep.txt
grep [!0-9] grep.txt
Sowmini- Posts : 2
Points : 2
Join date : 2010-03-03
Re: GREP TO EXTRACT NON DIGIT FROM EXPRESSION
hey buddy try this...
code:
#$^@#$%^&^@#$!@$%^&*(@#@$@%$&*(&#%$&#&(#%@!!%():-(:-(
code:
#$^@#$%^&^@#$!@$%^&*(@#@$@%$&*(&#%$&#&(#%@!!%():-(:-(
sanjidhkaran- Posts : 1
Points : 1
Join date : 2010-03-08
dats creepy sanjidh..:P
sanjidhkaran wrote:hey buddy try this...
code:
#$^@#$%^&^@#$!@$%^&*(@#@$@%$&*(&#%$&#&(#%@!!%():-(:-(
Jay Dave- Posts : 4
Points : 4
Join date : 2010-03-03
Re: GREP TO EXTRACT NON DIGIT FROM EXPRESSION
how to try that code... from where till where exactly!!! wat happens!!
jeeva- Posts : 50
Points : 93
Join date : 2010-03-04
Re: GREP TO EXTRACT NON DIGIT FROM EXPRESSION
this code is being accepted... is that the thing!!!
jeeva- Posts : 50
Points : 93
Join date : 2010-03-04
Re: GREP TO EXTRACT NON DIGIT FROM EXPRESSION
sanjidhkaran wrote:hey buddy try this...
code:
#$^@#$%^&^@#$!@$%^&*(@#@$@%$&*(&#%$&#&(#%@!!%():-(:-(
wat r u trying to say???
Permissions in this forum:
You cannot reply to topics in this forum
|
|