1753767 Members
5864 Online
108799 Solutions
New Discussion юеВ

Re: grep problem

 
SOLVED
Go to solution
pareshan
Regular Advisor

grep problem

When I grep stdlist with ls -al i got a huge output because I think there are so many logs file linked to some location and which contains name stdlist but just I want is stdlist in the filename in the local server not in the link


here is what i have got and what i want if anyone can help me with this.

i just want all the files which has stdlist name in the current server and i dont care where they have linked to
like i want this
stdlist -> /tlglogs/twsprd82/stdlist
but i dont want this
BLBESLBENREXT_B04022008010078_IND_20080207_231710.log -> /usr/local/TWS/stdlist

you can see stdlist is in the link so its also giving me in the output but i dont want it

this is what i have got
ll|grep stdlist
lrwxrwxr-x 1 twsprd82 oper 54 Feb 7 2008 BLBEADJEXT_B04022008010078_IND_20080207_231710.log -> /usr/local/TWS/TWSREJ82/stdlist/2008.02.07/O10899.2317
lrwxrwxr-x 1 twsprd82 oper 54 Feb 7 2008 BLBEBILLEXT_B04022008010078_IND_20080207_231710.log -> /usr/local/TWS/TWSREJ82/stdlist/2008.02.07/O10933.2317
lrwxrwxr-x 1 twsprd82 oper 54 Feb 7 2008 BLBEBLMSGEXT_B04022008010078_IND_20080207_231710.log -> /usr/local/TWS/TWSREJ82/stdlist/2008.02.07/O10946.2317
lrwxrwxr-x 1 twsprd82 oper 54 Feb 7 2008 BLBEBLSTEXT_B04022008010078_IND_20080207_231731.log -> /usr/local/TWS/TWSREJ82/stdlist/2008.02.07/O13927.2317
lrwxrwxr-x 1 twsprd82 oper 54 Feb 7 2008 BLBEBSUBEXT_B04022008010078_IND_20080207_231711.log -> /usr/local/TWS/TWSREJ82/stdlist/2008.02.07/O10965.2317
lrwxrwxr-x 1 twsprd82 oper 54 Feb 7 2008 BLBECANCTNEXT_B04022008010078_IND_20080207_231710.log -> /usr/local/TWS/TWSREJ82/stdlist/2008.02.07/O10858.2317
lrwxrwxr-x 1 twsprd82 oper 54 Feb 7 2008 BLBECAUEXT_B04022008010078_IND_20080207_231711.log -> /usr/local/TWS/TWSREJ82/stdlist/2008.02.07/O10983.2317
lrwxrwxr-x 1 twsprd82 oper 54 Feb 7 2008 BLBECHGEXT_B04022008010078_IND_20080207_231710.log -> /usr/local/TWS/TWSREJ82/stdlist/2008.02.07/O10915.2317
lrwxrwxr-x 1 twsprd82 oper 54 Feb 7 2008 BLBECUSGEXT_B04022008010078_IND_20080207_231711.log -> /usr/local/TWS/TWSREJ82/stdlist/2008.02.07/O11002.2317
lrwxrwxr-x 1 twsprd82 oper 54 Feb 7 2008 BLBEEQPEXT_B04022008010078_IND_20080207_231711.log -> /usr/local/TWS/TWSREJ82/stdlist/2008.02.07/O11056.2317
lrwxrwxr-x 1 twsprd82 oper 54 Feb 7 2008 BLBEINCFTREXT_B04022008010078_IND_20080207_231711.log -> /usr/local/TWS/TWSREJ82/stdlist/2008.02.07/O11038.2317
lrwxrwxr-x 1 twsprd82 oper 54 Feb 7 2008 BLBEIPEXT_B04022008010078_IND_20080207_231711.log -> /usr/local/TWS/TWSREJ82/stdlist/2008.02.07/O11137.2317
lrwxrwxr-x 1 twsprd82 oper 54 Feb 7 2008 BLBEIPUSGEXT_B04022008010078_IND_20080207_231711.log -> /usr/local/TWS/TWSREJ82/stdlist/2008.02.07/O11095.2317
lrwxrwxr-x 1 twsprd82 oper 54 Feb 7 2008 BLBEMPEXT_B04022008010078_IND_20080207_231710.log -> /usr/local/TWS/TWSREJ82/stdlist/2008.02.07/O10878.2317
lrwxrwxr-x 1 twsprd82 oper 54 Feb 7 2008 BLBEPIEXT_B04022008010078_IND_20080207_231710.log -> /usr/local/TWS/TWSREJ82/stdlist/2008.02.07/O10884.2317
lrwxrwxr-x 1 twsprd82 oper 54 Feb 7 2008 BLBEPYMEXT_B04022008010078_IND_20080207_231711.log -> /usr/local/TWS/TWSREJ82/stdlist/2008.02.07/O11022.2317
lrwxrwxr-x 1 twsprd82 oper 54 Feb 7 2008 BLBEREEXT_B04022008010078_IND_20080207_231710.log -> /usr/local/TWS/TWSREJ82/stdlist/2008.02.07/O10867.2317
lrwxrwxr-x 1 twsprd82 oper 54 Feb 7 2008 BLBEROLLEXT_B04022008010078_IND_20080207_231711.log -> /usr/local/TWS/TWSREJ82/stdlist/2008.02.07/O11176.2317
lrwxrwxr-x 1 twsprd82 oper 54 Feb 7 2008 BLBESHRGRPEXT_B04022008010078_IND_20080207_231711.log -> /usr/local/TWS/TWSREJ82/stdlist/2008.02.07/O11251.2317
lrwxrwxr-x 1 twsprd82 oper 54 Feb 7 2008 BLBESITINVEXT_B04022008010078_IND_20080207_231711.log -> /usr/local/TWS/TWSREJ82/stdlist/2008.02.07/O11084.2317
lrwxrwxr-x 1 twsprd82 oper 54 Feb 7 2008 BLBESLBENREXT_B04022008010078_IND_20080207_231710.log -> /usr/local/TWS/TWSREJ82/stdlist/2008.02.07/O10853.2317
lrwxrwxr-x 1 twsprd82 oper 25 Apr 10 2007 stdlist -> /tlglogs/twsprd82/stdlist

can anybody help me how can i just grep the first part where stdlist is there not in the link part

Thanks in advance
9 REPLIES 9
Nido
Trusted Contributor

Re: grep problem

Hi,

>>>>ll|grep stdlist
Correct me, Is this you want:
ll |grep stdlist |grep -v "^l"

hth
" Let Villagers Be Happy!! "
James R. Ferguson
Acclaimed Contributor

Re: grep problem

Hi:

Instead of using 'grep' you could use 'awk' to match only the firat field:

# ls -al|awk '$9~/stdlist/ {print}'

...matches the nineth field and if it matches "stdlist" the whole line is printed.

Regards!

...JRF...

pareshan
Regular Advisor

Re: grep problem

Nido, thats not giving me any output I dont know why,
ll|grep stdlist|grep -v "^"
it prints nothing

James,

that works when I try that in the local server but when I do in remote server got some error

awk: Quitting
The source line is 1.
uid=388(gc1488) gid=20(users)
syntax error The source line is 1.
The error context is
>>> ~ <<<
Ganesan R
Honored Contributor

Re: grep problem

Hi,

>>>Nido, thats not giving me any output I dont know why,
ll|grep stdlist|grep -v "^"
it prints nothing <<<<

You have missed the "l" after "^". Correct syntax is,

# ll|grep stdlist|grep -v ^l
Best wishes,

Ganesh.
Sunny123_1
Esteemed Contributor

Re: grep problem

Hi

Try to use grep -i option.

Regards
Sunny
James R. Ferguson
Acclaimed Contributor
Solution

Re: grep problem

Hi (again):

> James, that works when I try that in the local server but when I do in remote server got some error

Try this:

# ssh overthere -n ls -al|awk '$9~/stdlist/ {print}'

...without any additional encapsulating quotes.

Regards!

...JRF...

pareshan
Regular Advisor

Re: grep problem

james,
yeah that did work

Thanks alot

pareshan
Regular Advisor

Re: grep problem

problem solved with the help of james
Dennis Handly
Acclaimed Contributor

Re: grep problem

>can I just grep the first part where stdlist is there not in the link part

Simply use a better regexp:
ll -a | grep "stdlist.*->"