listing all files owned by user, double quest.

04/02/2008 - 05:52 von uche | Report spam
hey people,

i'd like to know why the following command doesn't necessarily list
all of the files owned by root in the temp directory.

ls -l /tmp | grep 'root'

...and how would i fix the command to get those processes "owned" by
root.

..another issues i am having is:

how do i use grep to get the longest word containing SS

thanks!!
 

Lesen sie die antworten

#1 Josef Moellers
04/02/2008 - 09:35 | Warnen spam
uche wrote:
hey people,



Just for the record: the is a "de." newsgroup, so the preferred langauge
would be German.

Thus said ...

i'd like to know why the following command doesn't necessarily list
all of the files owned by root in the temp directory.

ls -l /tmp | grep 'root'



/tmp might be a symbolic link to /var/tmp or /usr/tmp ...
Then "ls -l /tmp" would just show you this link.
If this is the case, try "ls -lL /tmp".
Also, a plain "ls -l" won't show files in subdirectories. You could try
"ls -lR" but you'll lose the directory information if you filter out lines.

In order to solve all this, you might want to look at the "find" command:
find /tmp -follow -uid 0 -print
or
find /tmp -follow -user root -print

...and how would i fix the command to get those processes "owned" by
root.



ITYM "files" rather than "processes".

..another issues i am having is:

how do i use grep to get the longest word containing SS



grep uses some kind of regular expression and they can't count.

Josef

These are my personal views and not those of Fujitsu Siemens Computers!
Josef Möllers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize (T. Pratchett)
Company Details: http://www.fujitsu-siemens.com/imprint.html

Ähnliche fragen