Operating System - Linux
1828960 Members
2330 Online
109986 Solutions
New Discussion

Re: confusion about grep ?

 
Huc_1
Honored Contributor

confusion about grep ?

Am I missing something ?

# ls -d /proc/* | grep [0-9]

If I use the above grep command as root and from the /root directory ... the grep command is working as i would expect it to ( it return the list of all the /proc/'pid' of curently running processes )

But if I cd to an other directory I get no /proc/'pid' return ?

I dont get this !?

also if replace [0-9] with [1-0] I do get some /proc/'pid' return ... why ? any ideas !


J-P ( Who will gladly assign points to any light on this !)

Smile I will feel the difference
7 REPLIES 7
Alexander Chuzhoy
Honored Contributor

Re: confusion about grep ?

I've just tried it on Fedora2 and on RHEL 3.
Works fine on both machines from any directory.
Looks like you have a misconfigured enviroment.
You can always post an output from env command + The version of Linux you use.

P.S. Reboot might help.
Huc_1
Honored Contributor

Re: confusion about grep ?

Hey Alexander ... nearly there ah ah ;-)

Keep it up I would gladly see you change hats ;-)

I run Fedora 2 on this setup and get the same result if I do this as root or as ordinary user

I will try this on an other system the I also configured for Fedora core 2

keep up the good work ;-)

J-P


Smile I will feel the difference
Bojan Nemec
Honored Contributor

Re: confusion about grep ?

Huc,

I try on RedHat 8. No root user. Now the problem is when you have some directories with names 0,1,2... The workarround is:

ls -d /proc/* | grep "[0-9]"

Try: echo [0-9] to see what hapens.

Bojan
Huc_1
Honored Contributor

Re: confusion about grep ?

Sorry for delay, have now checked on other Fedora core 2 system and on that system it works as expected

I have done an output of env as root to a file and compare the output the only diferrence is one is on LANG=fr_BE,UTF-8 (this one is giving problem) the other is on LANG=en_US,UTF-8 (this one is working as expected)

Bojan, you are right, your string works but I did not have directory's with 0,1,etc..

I will later (+- one hour hopfully , have some meeting) create a dummy user using LANG=en_US on and see if this give better output.

But as often I thing Alexander is right ! hence the reason why he deserves a crown !

J-P
Smile I will feel the difference
Alexander Chuzhoy
Honored Contributor

Re: confusion about grep ?

Thanks J.P. :)
You and "the Steven" were the inspiration.
zero points please.
Huc_1
Honored Contributor

Re: confusion about grep ?

Ok it is wrong env setup problem

this goes away when I change the LANG env to

#export LANG=en_US.UTF-8

I have also changed this in

/etc/sysconfig/i18n

Thank for your help.

Jean-Pierre
Smile I will feel the difference
Huc_1
Honored Contributor

Re: confusion about grep ?

enjoy, life

J-P
Smile I will feel the difference