[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Grep und regex



Moin,

* Andreas Schmidt <andy@space.wh1.tu-dresden.de> [2003-11-07 10:06]:
>bin gerade ueber ein Problem mit meinen regular expressions bei grep  
>gestolpert. Wollte in der Ausgabe von ps nach einer bestimmten pid  
>suchen:
>
>	PROC=`cat pid`
>	ps ax | grep "^$PROC"
>
>Das ganze funktionierte auch eine Weile -- bis auf einmal $PROC nur  
>vierstellig war. Da es auch fuenfstellige pids gab und die Ausgabe  
>rechtsbuendig ist (vor pid also white space war), wurde nichts mehr  
>gefunden.

Ich kann Dir nicht folgen. In Zeile 1 schreibst Du eine PID in die
Variable, richtig? Dann wirst Du in Zeile zwei diese PID auch finden.
Wo siehst Du, daß die Zahl der Ziffern ins Spiel kommt.

Ich würde es allerdings so machen:
    ps -ef | grep `cat pid`


Thorsten
-- 
Everyone has the right to freedom of opinion and expression; this right includes 
freedom to hold opinions without interference and to seek, receive and impart
information and ideas through any media and regardless of frontiers.
    - Universal Declaration of Human Rights, Article 19

Attachment: pgpw3CKf2HQ07.pgp
Description: PGP signature


Reply to: