Re: questions relating to the ls and grep command
On Wed, Jan 08, 2003 at 03:35:38PM +0000, Colin Watson wrote:
> On Wed, Jan 08, 2003 at 03:49:00PM +0100, Robert Land wrote:
> > Would someone kindly explain when to use the
> > "ls -d" command? The --help notes this would
> > list the directory entries - which puzzles me
> > a bit because I had never thought of there
> > may be more than one!
> Here's an example of the difference. Say I want to look at all the
> directories ssh has created in /tmp:
> [cjwatson@riva /tmp]$ ls -l ssh-*
> total 0
> srwxrwxr-x 1 cjwatson cjwatson 0 Jan 1 18:41 agent.7501
> look at (say) the permissions on the directories themselves. So I add
> [cjwatson@riva /tmp]$ ls -ld ssh-*
> drwx------ 2 cjwatson cjwatson 1024 Jan 1 18:41 ssh-XXEUZa6m
> drwx------ 2 cjwatson cjwatson 1024 Dec 20 00:55 ssh-XXF7Y8Co
> drwx------ 2 cjwatson cjwatson 1024 Jan 8 13:29 ssh-XXjSQEpa
> drwx------ 2 cjwatson cjwatson 1024 Jan 8 15:27 ssh-XXwEBydX
> I've used -l because it seems more useful in an example, but it's not
> necessary to see the difference. The point is that -d controls whether
> ls shows the entries inside directory names you pass on the command
> line. It's not so useful if you don't pass any directory names on the
> command line, since it will then list only the current directory entry
Yes exactly, I did a simple "ls -d" without any
dir-name which resulted in a neocortex getting
caught in a endless loop producing errors....
> > Then, when wanting ls only to plot the names
> > of the subdirectories in the current directory,
> > I key "ls -F|grep" or "ls -p|grep".
> > Is this the only way,
Have I written this? - again one of my bad habits
to skip/mangle my own thoughts.
What I had used was "ls -F|grep /" or "ls -p|grep /"
but found it rather silly because quite complicated
for a simple wish.
> You probably want something like:
> ls -l | grep '^d'
This is what perl users usually recommend :^) ?
> > and why do the -p and -F options do not seem to differ in any way?
> They differ slightly. -F appends a * to executable files, while -p
Again my "mangle" problem. Reading this I remembered the
paragraph in the info. Too much coffee on that day...
Thanks to Bob for the very helpful url
too - puh what a awfull lot to read....