[Novalug] question about ls
Peter Larsen
plarsen at famlarsen.homelinux.com
Mon Jan 16 11:40:09 EST 2012
On Mon, 2012-01-16 at 11:11 -0500, Nino R. Pereira wrote:
> On 01/16/2012 09:58 AM, Peter Larsen wrote:
> > On Mon, 2012-01-16 at 08:55 -0500, Nino R. Pereira wrote:
> >> Thanks to all who replied.
> >>
> >> I'm sorry to say that I mislead you. My command was not simply
> >>
> >> ls -l
> >>
> >> but it was
> >>
> >> ls -l cryst*
> > See - I knew something wasn't right :)
> yes ;-(
> >
> > ls -dl cryst*
> >
> this actually gives only the directory, not what's in it.
I thought that's what you wanted.
"ls" gives you just one level down - always. If you want better control,
use find.
$ find . -type f -print
And it shows you all the files from your current directory and down -
with path so you can easily tell the difference. If you want additional
conditions, find is your friend - ls is not.
> When I try to see if 'ls' has an option like tree, -L, I look
> in the man pages, but because these are so long I do
> man ls > temp
No such thing with ls.
> which gives me a file I want to search for '-L' with grep.
> But, this doesn't work because in the command
>
> cat temp | grep -L
Ouch - you shouldn't have to do it so complicated. Use find instead if
you want to really do crazy searches on your file names.
>
> grep thinks '-L' is an option, and when I do
>
> cat temp | grep '-L' (or even 'grep -i '-L')
>
> it isn't any better.
As it should be. Anything after grep and before a pipe or > < is a grep
option.
>
> How do I get ls to tell me
>
> crystals:
> accounting orders quartz technical
As I pointed out, ls only prefixes if there are more than one option on
the command line (option being file/directory names).
Here's the output from my little test directory from yesterday:
[plarsen at boss crytals]$ find . -type f -print
./crystal3
./crystal8
./crystal9
./crystal5
./crystal10
./crystal6
./crystal4
./crystal7
./sub1/sub8
./sub1/sub10
./sub1/sub9
./sub1/sub5
./sub1/sub3
./sub1/sub7
./sub1/sub1
./sub1/sub4
./sub1/sub2
./sub1/sub6
./crystal2
./crystal1
Pretty clear what's what here. Note it doesn't show you empty
directories etc.
--
Best Regards
Peter Larsen
Wise words of the day:
NEVER RESPOND TO CRITICAL PRESS. IT IS A GAME YOU CAN ONLY LOSE, AND IT
MAKES US LOOK BAD.
-- Bruce Perens
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
Url : http://calypso.tux.org/pipermail/novalug/attachments/20120116/87ab17f7/attachment.bin
More information about the Novalug
mailing list