Re: list files but not directory

2009-08-21 Thread Todd Zullinger
ann kok wrote:
> any way to list files but not directory

Could you be more specific about what you want?

Possible solutions might be using 'ls -d' or 'find -type f' but it's
hard to say without knowing what you're trying to do.

-- 
ToddOpenPGP -> KeyID: 0xBEAF0CE3 | URL: www.pobox.com/~tmz/pgp
~~
Stenderup's Law:  The sooner you fall behind, the more time you will
have to catch up.



pgp7ptN3H3Qjb.pgp
Description: PGP signature
-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines

Re: list files but not directory

2009-08-21 Thread Todd Zullinger
(Please don't top post.)

ann kok wrote:
> ls -1 but I only want the file to list not directory

And do you just not want to see the contents of any directories or not
see them at all?  Using 'ls -d1' you would see the directory name in
the output, but not the files inside it.

To avoid that, I think you need to use find or some other tool, though
I'm not positive that there isn't a way to do it with ls that I don't
know about.  You could use 'find -mindepth 1 -maxdepth 1 -type f'
perhaps.

-- 
ToddOpenPGP -> KeyID: 0xBEAF0CE3 | URL: www.pobox.com/~tmz/pgp
~~
Everything the government touches turns to crap.
-- Ringo Starr



pgpQ47oSjrHIL.pgp
Description: PGP signature
-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines

Re: list files but not directory

2009-08-21 Thread Bryn M. Reeves
On Fri, 2009-08-21 at 05:17 -0700, ann kok wrote:
> ls -1 but I only want the file to list not directory

ls -l | grep -v '^d'

But that will also show you symlinks, fifos, device nodes etc.

Bryn.


-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: list files but not directory

2009-08-21 Thread ann kok
ls -1 but I only want the file to list not directory

thank you

--- On Fri, 8/21/09, Todd Zullinger  wrote:

> From: Todd Zullinger 
> Subject: Re: list files but not directory
> To: fedora-list@redhat.com
> Received: Friday, August 21, 2009, 8:02 AM
> ann kok wrote:
> > any way to list files but not directory
> 
> Could you be more specific about what you want?
> 
> Possible solutions might be using 'ls -d' or 'find -type f'
> but it's
> hard to say without knowing what you're trying to do.
> 
> -- 
> Todd        OpenPGP -> KeyID:
> 0xBEAF0CE3 | URL: www.pobox.com/~tmz/pgp
> ~~
> Stenderup's Law:  The sooner you fall behind, the more
> time you will
> have to catch up.
> 
> 
> -Inline Attachment Follows-
> 
> -- 
> fedora-list mailing list
> fedora-list@redhat.com
> To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
> Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


  __
Looking for the perfect gift? Give the gift of Flickr! 

http://www.flickr.com/gift/

-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: list files but not directory

2009-08-21 Thread Albert Graham

On 08/21/2009 12:58 PM, ann kok wrote:

Hi

any way to list files but not directory

Thank you


   __
The new Internet Explorer® 8 - Faster, safer, easier.  Optimized for Yahoo!  
Get it Now for Free! at http://downloads.yahoo.com/ca/internetexplorer/

   


Seems like a very reasonable request and its a shame that ls does not 
provide such an option (which I guess would be an extension to the -A 
option)


Anyhow, if its OK to use grep, try this.


ls -1A --indicator-style=slash |grep -v -E "/$"

The --indicator adds a / to the end of dirs, the grep excludes entries 
that end in /


Albert.





--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: list files but not directory

2009-08-21 Thread Hiisi

Hi

any way to list files but not directory

Thank you



ls -hl | grep ^-

--
Hiisi.
Registered Linux User #487982. Be counted at: http://counter.li.org/

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: list files but not directory

2009-08-21 Thread William Case
Hi;

On Fri, 2009-08-21 at 13:36 +0100, Albert Graham wrote:
> On 08/21/2009 12:58 PM, ann kok wrote:
> > Hi
> >
> > any way to list files but not directory
> >
> > Thank you
> >
> >
> >__
> > The new Internet Explorer® 8 - Faster, safer, easier.  Optimized for Yahoo! 
> >  Get it Now for Free! at http://downloads.yahoo.com/ca/internetexplorer/
> >
> >
> 
> Seems like a very reasonable request and its a shame that ls does not 
> provide such an option (which I guess would be an extension to the -A 
> option)
> 

I remember asking about this four or five years ago when I first started
using Linux (RedHat). (It was the first question I asked on the users
mailing list.) 

Now that I am familiar with 'find' and 'grep' etc. I no longer worry
about it.  However, 'ls' is probably the first commandline command a
beginner learns.  It seems illogical, that 'ls' wouldn't have a flag
that just shows files when it has a flag for directories.  It can cost
newbies hours looking for a solution that isn't there.

Couldn't the shell maintainers just add an appropriate flag to show
files only?

-- 
Regards Bill
Fedora 11, Gnome 2.26.3
Evo.2.26.3, Emacs 23.1.1

-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: list files but not directory

2009-08-21 Thread Albert Graham

On 08/21/2009 03:35 PM, William Case wrote:

Hi;

On Fri, 2009-08-21 at 13:36 +0100, Albert Graham wrote:
   

On 08/21/2009 12:58 PM, ann kok wrote:
 

Hi

any way to list files but not directory

Thank you


__
The new Internet Explorer® 8 - Faster, safer, easier.  Optimized for Yahoo!  
Get it Now for Free! at http://downloads.yahoo.com/ca/internetexplorer/


   

Seems like a very reasonable request and its a shame that ls does not
provide such an option (which I guess would be an extension to the -A
option)

 


I remember asking about this four or five years ago when I first started
using Linux (RedHat). (It was the first question I asked on the users
mailing list.)

Now that I am familiar with 'find' and 'grep' etc. I no longer worry
about it.  However, 'ls' is probably the first commandline command a
beginner learns.  It seems illogical, that 'ls' wouldn't have a flag
that just shows files when it has a flag for directories.  It can cost
newbies hours looking for a solution that isn't there.

   
Couldn't the shell maintainers just add an appropriate flag to show

files only?

   


It would probably be easier to hack the ls source and extend the -A 
functionality.





--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: list files but not directory

2009-08-21 Thread William Case
Hi;

On Fri, 2009-08-21 at 18:12 +0100, Albert Graham wrote:
> On 08/21/2009 03:35 PM, William Case wrote:

> > Now that I am familiar with 'find' and 'grep' etc. I no longer worry
> > about it.  However, 'ls' is probably the first commandline command a
> > beginner learns.  It seems illogical, that 'ls' wouldn't have a flag
> > that just shows files when it has a flag for directories.  It can cost
> > newbies hours looking for a solution that isn't there.
> >
> >
> > Couldn't the shell maintainers just add an appropriate flag to show
> > files only?
> >
> >
> 
> It would probably be easier to hack the ls source and extend the -A 
> functionality.

Perhaps.  But in the end, it is not something I NEED now.  But when I
read the original post I thought back to my first days using Linux.  It
was a chore figuring out what the color code for files etc. meant, or
what the identifying symbols where for etc. when all I wanted was to see
if my disappearing file was in which directory.  It was, to say the
least, unnecessarily frustrating at the time.

A clean uncomplicated list of files would have been useful back then.

I would think something like the following would be useful:

]$ ls -z would show a list of just the files in the current directory
similar to the way 'ls' shows an unadorned list of directory contents.

('-z' is not a good mnemonic choice for "files" but seems to be
available as an option/flag.)

-z should have the property of being able to combine with other ls
options 

eg
]$ ls -za -- to show dot files as well, or,
]$ ls -zl -- to show long list format of just files, or,
]$ ls -zlA /some/other/directory's/files/ -- to show long list format of
all files in a directory other than the current directory.

Without hacking ls -A,  but by writing "alias lsf='ls -hl | grep ^-'" to
bashrc, lsf works well enough for the current directory.  I still think
an addition to the options available in 'ls' would be helpful.

I am just wondering if this has been requested before or if this is a
request for enhancement that would not be entertained by the maintainers
of coreutils.
 

-- 
Regards Bill
Fedora 11, Gnome 2.26.3
Evo.2.26.3, Emacs 23.1.1

-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: list files but not directory

2009-08-21 Thread Steven W. Orr
On 08/21/09 10:35, quoth William Case:
> Hi;
> 
>> Seems like a very reasonable request and its a shame that ls does not 
>> provide such an option (which I guess would be an extension to the -A 
>> option)
>> 
> 
> I remember asking about this four or five years ago when I first started 
> using Linux (RedHat). (It was the first question I asked on the users 
> mailing list.)
> 
> Now that I am familiar with 'find' and 'grep' etc. I no longer worry about
> it.  However, 'ls' is probably the first commandline command a beginner
> learns.  It seems illogical, that 'ls' wouldn't have a flag that just shows
> files when it has a flag for directories.  It can cost newbies hours
> looking for a solution that isn't there.
> 
> Couldn't the shell maintainers just add an appropriate flag to show files
> only?

My take is that the ls command is already so heavily loaded with options that
you're better off rolling your own. For example, let's beuild two new
commands. lsd and lsD. lsd will only list directories and lsD will only list
nondirectories.

lsD ()
{
typeset args1="$1"
typeset args2="$2"

ls -la $args1 | awk '!/^d/ {print $9}' | xargs ls $args2
}

Now you can try things like
lsd '-d x*' -l

and lsd is left as an exercise for the student. ;-)

-- 
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net



signature.asc
Description: OpenPGP digital signature
-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines

Re: list files but not directory

2009-08-21 Thread ann kok
Thank you for all help

I am using fedora 10

but ls -z doesn't work to me!



--- On Fri, 8/21/09, William Case  wrote:

> From: William Case 
> Subject: Re: list files but not directory
> To: "Community assistance, encouragement, and advice for using Fedora." 
> 
> Received: Friday, August 21, 2009, 1:51 PM
> Hi;
> 
> On Fri, 2009-08-21 at 18:12 +0100, Albert Graham wrote:
> > On 08/21/2009 03:35 PM, William Case wrote:
> 
> > > Now that I am familiar with 'find' and 'grep'
> etc. I no longer worry
> > > about it.  However, 'ls' is probably the
> first commandline command a
> > > beginner learns.  It seems illogical, that
> 'ls' wouldn't have a flag
> > > that just shows files when it has a flag for
> directories.  It can cost
> > > newbies hours looking for a solution that isn't
> there.
> > >
> > >    
> > > Couldn't the shell maintainers just add an
> appropriate flag to show
> > > files only?
> > >
> > >    
> > 
> > It would probably be easier to hack the ls source and
> extend the -A 
> > functionality.
> 
> Perhaps.  But in the end, it is not something I NEED
> now.  But when I
> read the original post I thought back to my first days
> using Linux.  It
> was a chore figuring out what the color code for files etc.
> meant, or
> what the identifying symbols where for etc. when all I
> wanted was to see
> if my disappearing file was in which directory.  It
> was, to say the
> least, unnecessarily frustrating at the time.
> 
> A clean uncomplicated list of files would have been useful
> back then.
> 
> I would think something like the following would be
> useful:
> 
> ]$ ls -z would show a list of just the files in the current
> directory
> similar to the way 'ls' shows an unadorned list of
> directory contents.
> 
> ('-z' is not a good mnemonic choice for "files" but seems
> to be
> available as an option/flag.)
> 
> -z should have the property of being able to combine with
> other ls
> options 
> 
> eg
> ]$ ls -za -- to show dot files as well, or,
> ]$ ls -zl -- to show long list format of just files, or,
> ]$ ls -zlA /some/other/directory's/files/ -- to show long
> list format of
> all files in a directory other than the current directory.
> 
> Without hacking ls -A,  but by writing "alias lsf='ls
> -hl | grep ^-'" to
> bashrc, lsf works well enough for the current
> directory.  I still think
> an addition to the options available in 'ls' would be
> helpful.
> 
> I am just wondering if this has been requested before or if
> this is a
> request for enhancement that would not be entertained by
> the maintainers
> of coreutils.
>  
> 
> -- 
> Regards Bill
> Fedora 11, Gnome 2.26.3
> Evo.2.26.3, Emacs 23.1.1
> 
> -- 
> fedora-list mailing list
> fedora-list@redhat.com
> To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
> Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines
> 


  __
Looking for the perfect gift? Give the gift of Flickr! 

http://www.flickr.com/gift/

-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: list files but not directory

2009-08-21 Thread Kevin J. Cummings
On 08/21/2009 04:06 PM, ann kok wrote:
> Thank you for all help
> 
> I am using fedora 10
> 
> but ls -z doesn't work to me!

He didn't say it existed, he just hypothesized a possible command line
option to do what you wanted.  B^)

-- 
Kevin J. Cummings
kjch...@rcn.com
cummi...@kjchome.homeip.net
cummi...@kjc386.framingham.ma.us
Registered Linux User #1232 (http://counter.li.org)

-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: list files but not directory

2009-08-21 Thread Marko Vojinovic
On Friday 21 August 2009 19:22:47 Steven W. Orr wrote:
[snip]
> and lsd is left as an exercise for the student. ;-)

ROTFLMAO! 

Best, :-)
Marko


-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: list files but not directory

2009-08-21 Thread Todd Zullinger
Steven W. Orr wrote:
> and lsd is left as an exercise for the student. ;-)

Ha!  I've had lsa and lsd as simple aliases for ages and always
chuckle about their alternate meanings when I use them (which isn't
all that often, as I trained myself to type the extra ' -{A,d}'
anyway). ;)

Thanks for a combining a handy tip with a good laugh Steven!

-- 
ToddOpenPGP -> KeyID: 0xBEAF0CE3 | URL: www.pobox.com/~tmz/pgp
~~
In order to make an apple pie from scratch, you must first create the
universe.
-- Carl Sagan, Cosmos



pgphhLs9BlS8G.pgp
Description: PGP signature
-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines

Re: list files but not directory

2009-08-22 Thread Tim
On Fri, 2009-08-21 at 10:35 -0400, William Case wrote:
> It seems illogical, that 'ls' wouldn't have a flag that just shows
> files when it has a flag for directories.

Though that flag "ls -d" has a completely different purpose (show
directory names, rather than go into them and list their contents).

-- 
[...@localhost ~]$ uname -r
2.6.27.25-78.2.56.fc9.i686

Don't send private replies to my address, the mailbox is ignored.  I
read messages from the public lists.



-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: list files but not directory

2009-08-22 Thread William Case
Hi Tim;
On Sat, 2009-08-22 at 16:58 +0930, Tim wrote:
> On Fri, 2009-08-21 at 10:35 -0400, William Case wrote:
> > It seems illogical, that 'ls' wouldn't have a flag that just shows
> > files when it has a flag for directories.
> 
> Though that flag "ls -d" has a completely different purpose (show
> directory names, rather than go into them and list their contents).
> 
True.  But whatever its purpose, it does give me a list of directory
names.

All that I am saying is that it would be handy to have a simple util
that listed file names.  I suggest 'ls' because it is probably the most
used and first learned listing utility and therefore would be the place
to have it.  It would be useful to beginners (particularly those who do
not yet have any idea what a regexp is) and for script writing or piping
to sed, awk, grep or a new file (or for appending).

The idea is getting no positive responses, so I will drop it.

-- 
Regards Bill
Fedora 11, Gnome 2.26.3
Evo.2.26.3, Emacs 23.1.1

-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: list files but not directory

2009-08-22 Thread Patrick O'Callaghan
On Sat, 2009-08-22 at 03:59 -0400, William Case wrote:
> Hi Tim;
> On Sat, 2009-08-22 at 16:58 +0930, Tim wrote:
> > On Fri, 2009-08-21 at 10:35 -0400, William Case wrote:
> > > It seems illogical, that 'ls' wouldn't have a flag that just shows
> > > files when it has a flag for directories.
> > 
> > Though that flag "ls -d" has a completely different purpose (show
> > directory names, rather than go into them and list their contents).
> > 
> True.  But whatever its purpose, it does give me a list of directory
> names.

In fact it lists *all* its arguments as usual (the default being ".", as
always), except that those which are directories are not listed
recursively. It doesn't "give a list of directory names", unless that's
what the arguments happen to be.

There are no flags to ls which mean "ignore any arguments which belong
to this class of object".

> All that I am saying is that it would be handy to have a simple util
> that listed file names.

If you want to filter out directories, use grep, as several people have
pointed out. That's the Unix Way (tm).

>  I suggest 'ls' because it is probably the most
> used and first learned listing utility and therefore would be the place
> to have it.  It would be useful to beginners (particularly those who do
> not yet have any idea what a regexp is) and for script writing or piping
> to sed, awk, grep or a new file (or for appending).

Said beginners need to learn that *directories are files* (and devices
are files, named pipes are files, etc.). This is an important concept
which should not be hidden.

poc

-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: list files but not directory

2009-08-22 Thread William Case
Hi Patrick;

To continue as a conversation, but not belabour the point.

On Sat, 2009-08-22 at 11:14 -0430, Patrick O'Callaghan wrote:
> On Sat, 2009-08-22 at 03:59 -0400, William Case wrote:
> > Hi Tim;
> > On Sat, 2009-08-22 at 16:58 +0930, Tim wrote:
> > > On Fri, 2009-08-21 at 10:35 -0400, William Case wrote:
> > > > It seems illogical, that 'ls' wouldn't have a flag that just shows
> > > > files when it has a flag for directories.
> > > 
> > > Though that flag "ls -d" has a completely different purpose (show
> > > directory names, rather than go into them and list their contents).
> > > 
> > True.  But whatever its purpose, it does give me a list of directory
> > names.
> 
> In fact it lists *all* its arguments as usual (the default being ".", as
> always), except that those which are directories are not listed
> recursively. It doesn't "give a list of directory names", unless that's
> what the arguments happen to be.
> 

Yea, I know.  But by reading the ls man page and a couple of experiments
I was able to get ls -d ./* to print a list of the directories to stout.

> There are no flags to ls which mean "ignore any arguments which belong
> to this class of object".
> 
And isn't that a shame.

> > All that I am saying is that it would be handy to have a simple util
> > that listed file names.
> 
> If you want to filter out directories, use grep, as several people have
> pointed out. That's the Unix Way (tm).

But why make people use grep ( a whole to learning curve; particularly
if you are new) when I simple option could do it for you.

> 
> >  I suggest 'ls' because it is probably the most
> > used and first learned listing utility and therefore would be the place
> > to have it.  It would be useful to beginners (particularly those who do
> > not yet have any idea what a regexp is) and for script writing or piping
> > to sed, awk, grep or a new file (or for appending).
> 
> Said beginners need to learn that *directories are files* (and devices
> are files, named pipes are files, etc.). This is an important concept
> which should not be hidden.

I don't limit my remarks to "Said beginners", I think the option would
be useful to practised Linux users too.  But remembering the
befuddlement, confusion and fluster I felt as a new user did bring the
issue back to mind.

Nor do I think it is the place of any Linux distribution to decide when
and what users should learn.  To me, that's M$ type of thinking.
Perhaps some users can't remember as far back as when they first started
using Linux or Unix, or perhaps they have always had an intuitive grasp
of how computers work.

Or, maybe, there is just the natural old pro desire to force an
unnecessarily onerous initiation period on beginners. 

In lieu of providing an additional option to 'ls' coreutils could
provide an 'lsf' command that would print the simple information that is
desired.  I didn't jump into this thread because it was something I
REALLY NEEDED, but because I thought it might be useful to others.

Such an lsf command should be a kind of a command line alternative to
gui file browsers like nautilus.

-- 
Regards Bill
Fedora 11, Gnome 2.26.3
Evo.2.26.3, Emacs 23.1.1

-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: list files but not directory

2009-08-22 Thread Bruno Wolff III
On Sat, Aug 22, 2009 at 03:59:30 -0400,
  William Case  wrote:
> 
> All that I am saying is that it would be handy to have a simple util
> that listed file names.  I suggest 'ls' because it is probably the most
> used and first learned listing utility and therefore would be the place
> to have it.  It would be useful to beginners (particularly those who do
> not yet have any idea what a regexp is) and for script writing or piping
> to sed, awk, grep or a new file (or for appending).
> 
> The idea is getting no positive responses, so I will drop it.

find . -type f

-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: list files but not directory

2009-08-22 Thread Phil Meyer

ann kok wrote:
Hi 


any way to list files but not directory
  


Some time ago, there were at least 116 useful combinations of arguments 
to ls.


UNIX is 40 years old, and ls was there ...

Whenever this question pops up, and it does quite often, I respond with 
a question.


"Why do you want to see just files?"
and
"What file types are you interested in?"

Which usually gets a response like:  "How many different file types are 
there?"  for which the answer is: "At least `egrep -v "^#" 
/usr/share/file/magic | wc -l`" (10179)


There are also some blank lines in the file, but you get the idea.

So now the question is:  "What files types do you want ls to list?"
and
"Did you try the 'F' argument?"

The 'F' argument to ls will attach a single character to the file name 
in order to identify what file types they are.  Of course, only the 
common file types can be identified this way -- there are only some 96 
displayable characters.


So we are back to the original question:

"What is it you are trying to do?"

The answer to that is very likely different from what you expected.

Good luck!

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: list files but not directory

2009-08-22 Thread Marko Vojinovic
> On Sat, Aug 22, 2009 at 03:59:30 -0400,
>   William Case  wrote:
> > All that I am saying is that it would be handy to have a simple util
> > that listed file names.  I suggest 'ls' because it is probably the most
> > used and first learned listing utility and therefore would be the place
> > to have it.  It would be useful to beginners (particularly those who do
> > not yet have any idea what a regexp is) and for script writing or piping
> > to sed, awk, grep or a new file (or for appending).

There is just one thing that baffles me here --- isn't a directory also a file? 
Given that, what you ask for is not an option to list only files, it is an 
option to list everything except directories. In other words, you are asking 
for an option that says "list the directory contents, but omit certain 
things".

The more appropriate way to do this is to use some form of filtering. Such a 
thing does not naturally fit into a list of options of ls, IMHO. What you 
actually do is perform two operations here --- list the contents, and then 
filter it to display only some subset. Two operations should be done using two 
commands, the Unix Way. And the filtering approach gives you more flexibility 
what file types to filter out. For example, is /dev/sda a file or a directory? 
How would this hypothetical ls option behave in this case? List it or not?

There are not *just directories and files* on the system. There are
*just files*. And these files might be regular files, directories, devices, 
stdin/stdout, and who knows what else. You are proposing to add a single 
option to ls in order to filter out one of these types. Why only this one type? 
Put a whole bunch of options in ls which could list only regular files, or only 
character devices, or only hidden directories or... Or better yet, don't put 
any of that crap into ls, but pipe the ls output and filter it using a more 
appropriate tool.

The completely analogous situation is with paging the output of ls. When I 
first used ls on a directory with lots of files, the natural idea for me was to 
look into its man page to find some option that would split the output into 
several screens and display them one by one. I failed to find such an option. 
After some digging, I found that this is done via a pipe to less:

ls | less

And then after some learning I understood that this is actually the better way 
to do it (more powerful, more flexible, more clean, more useful). The same 
situation is here with listing only non-directories. 

The main problem is not lack of functionality, but that Windows-converts have 
a frame of mind that makes a distinction between "directory" and "file" 
concepts, and believe these concepts are fundamentally different and non-
overlapping. This is a Bad Idea, and it seems more appropriate to educate 
users than to add options to ls which make it do things it is not designed 
for.

Just remember: "Do one simple thing and do i well." ;-)

HTH, :-)
Marko


-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: list files but not directory

2009-08-22 Thread Marko Vojinovic

William Case  wrote:
> The idea is getting no positive responses, so I will drop it.

Oh, and a word of advice: if you get no positive responses for some idea, 
don't just drop it, but instead try to understand why there are no positive 
responses. Usually you can learn something new and maybe correct your own 
point of view on the subject. Being open minded is essential for better 
thinking. ;-)

Best, :-)
Marko



-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: list files but not directory

2009-08-22 Thread William Case
Hi Marko;

On Sat, 2009-08-22 at 21:05 +0100, Marko Vojinovic wrote:
> > On Sat, Aug 22, 2009 at 03:59:30 -0400,
> >   William Case  wrote:
> > > All that I am saying is that it would be handy to have a simple util
> > > that listed file names.  I suggest 'ls' because it is probably the most
> > > used and first learned listing utility and therefore would be the place
> > > to have it.  It would be useful to beginners (particularly those who do
> > > not yet have any idea what a regexp is) and for script writing or piping
> > > to sed, awk, grep or a new file (or for appending).
> 
> There is just one thing that baffles me here --- isn't a directory also a 
> file? 
> Given that, what you ask for is not an option to list only files, it is an 
> option to list everything except directories. In other words, you are asking 
> for an option that says "list the directory contents, but omit certain 
> things".
> 
> The more appropriate way to do this is to use some form of filtering. Such a 
> thing does not naturally fit into a list of options of ls, IMHO. What you 
> actually do is perform two operations here --- list the contents, and then 
> filter it to display only some subset. Two operations should be done using 
> two 
> commands, the Unix Way. And the filtering approach gives you more flexibility 
> what file types to filter out. For example, is /dev/sda a file or a 
> directory? 
> How would this hypothetical ls option behave in this case? List it or not?
> 
> There are not *just directories and files* on the system. There are
> *just files*. And these files might be regular files, directories, devices, 
> stdin/stdout, and who knows what else. You are proposing to add a single 
> option to ls in order to filter out one of these types. Why only this one 
> type? 
> Put a whole bunch of options in ls which could list only regular files, or 
> only 
> character devices, or only hidden directories or... Or better yet, don't put 
> any of that crap into ls, but pipe the ls output and filter it using a more 
> appropriate tool.
> 
> The completely analogous situation is with paging the output of ls. When I 
> first used ls on a directory with lots of files, the natural idea for me was 
> to 
> look into its man page to find some option that would split the output into 
> several screens and display them one by one. I failed to find such an option. 
> After some digging, I found that this is done via a pipe to less:
> 
> ls | less
> 
> And then after some learning I understood that this is actually the better 
> way 
> to do it (more powerful, more flexible, more clean, more useful). The same 
> situation is here with listing only non-directories. 
> 
> The main problem is not lack of functionality, but that Windows-converts have 
> a frame of mind that makes a distinction between "directory" and "file" 
> concepts, and believe these concepts are fundamentally different and non-
> overlapping. 

That is exactly where I was coming from and believe that that defines
the problem the original poster had.

> This is a Bad Idea, and it seems more appropriate to educate 
> users than to add options to ls which make it do things it is not designed 
> for.
> 
> Just remember: "Do one simple thing and do i well." ;-)

Marko, you have given the best explanation and counter argument yet to
this post.

However, I could tell you several (delightful) horror stories of hours
and hours I wasted when I first came to Linux from Windows.  I bet there
are others who have had an equalling trying experience.  Don't get me
wrong, Linux is by far the best operating system.  But I still find
myself from time to time trying to solve problems by using 'MicroSoft
Intuition'.  That usually means looking for a complex answer when, in
Linux, a simple answer will do.

In any case, I always keep my eye open for the newbies for whom
'intuition' is not working.  They often get dismissed as if they should
know better.

I guess that all I was proposing was giving people some transitional
tools.  To me, a regular file will always be a file different from the
others.

-- 
Regards Bill
Fedora 11, Gnome 2.26.3
Evo.2.26.3, Emacs 23.1.1

-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: list files but not directory

2009-08-22 Thread Mikkel L. Ellertson
Marko Vojinovic wrote:
> 
> There is just one thing that baffles me here --- isn't a directory also a 
> file? 
> Given that, what you ask for is not an option to list only files, it is an 
> option to list everything except directories. In other words, you are asking 
> for an option that says "list the directory contents, but omit certain 
> things".
> 
> The more appropriate way to do this is to use some form of filtering. Such a 
> thing does not naturally fit into a list of options of ls, IMHO. What you 
> actually do is perform two operations here --- list the contents, and then 
> filter it to display only some subset. Two operations should be done using 
> two 
> commands, the Unix Way. And the filtering approach gives you more flexibility 
> what file types to filter out. For example, is /dev/sda a file or a 
> directory? 
> How would this hypothetical ls option behave in this case? List it or not?
> 
> There are not *just directories and files* on the system. There are
> *just files*. And these files might be regular files, directories, devices, 
> stdin/stdout, and who knows what else. You are proposing to add a single 
> option to ls in order to filter out one of these types. Why only this one 
> type? 
> Put a whole bunch of options in ls which could list only regular files, or 
> only 
> character devices, or only hidden directories or... Or better yet, don't put 
> any of that crap into ls, but pipe the ls output and filter it using a more 
> appropriate tool.
> 
> The completely analogous situation is with paging the output of ls. When I 
> first used ls on a directory with lots of files, the natural idea for me was 
> to 
> look into its man page to find some option that would split the output into 
> several screens and display them one by one. I failed to find such an option. 
> After some digging, I found that this is done via a pipe to less:
> 
> ls | less
> 
> And then after some learning I understood that this is actually the better 
> way 
> to do it (more powerful, more flexible, more clean, more useful). The same 
> situation is here with listing only non-directories. 
> 
> The main problem is not lack of functionality, but that Windows-converts have 
> a frame of mind that makes a distinction between "directory" and "file" 
> concepts, and believe these concepts are fundamentally different and non-
> overlapping. This is a Bad Idea, and it seems more appropriate to educate 
> users than to add options to ls which make it do things it is not designed 
> for.
> 
> Just remember: "Do one simple thing and do i well." ;-)
> 
And to carry this one step farther, you can create aliases or
function to do things you require often. For example, you could use
something like this:

function lsp() { ls $@ && less }

so that you could run lsd instead of running "ls | less".

Mikkel
-- 

  Do not meddle in the affairs of dragons,
for thou art crunchy and taste good with Ketchup!



signature.asc
Description: OpenPGP digital signature
-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines

Re: list files but not directory

2009-08-22 Thread Patrick O'Callaghan
On Sat, 2009-08-22 at 13:00 -0400, William Case wrote:
> Hi Patrick;
> 
> To continue as a conversation, but not belabour the point.
> 
> On Sat, 2009-08-22 at 11:14 -0430, Patrick O'Callaghan wrote:
> > On Sat, 2009-08-22 at 03:59 -0400, William Case wrote:
> > > Hi Tim;
> > > On Sat, 2009-08-22 at 16:58 +0930, Tim wrote:
> > > > On Fri, 2009-08-21 at 10:35 -0400, William Case wrote:
> > > > > It seems illogical, that 'ls' wouldn't have a flag that just shows
> > > > > files when it has a flag for directories.
> > > > 
> > > > Though that flag "ls -d" has a completely different purpose (show
> > > > directory names, rather than go into them and list their contents).
> > > > 
> > > True.  But whatever its purpose, it does give me a list of directory
> > > names.
> > 
> > In fact it lists *all* its arguments as usual (the default being ".", as
> > always), except that those which are directories are not listed
> > recursively. It doesn't "give a list of directory names", unless that's
> > what the arguments happen to be.
> > 
> 
> Yea, I know.  But by reading the ls man page and a couple of experiments
> I was able to get ls -d ./* to print a list of the directories to stout.

"ls -d ./*" is exactly the same as "ls -d *", which in turn is the same
as "ls". Try sending the output of each of these to a temp file (not in
the current directory of course :-) and running diff on them.

> > There are no flags to ls which mean "ignore any arguments which belong
> > to this class of object".
> > 
> And isn't that a shame.

That's a matter of opinion of course, but many people think ls already
has too many options. As the old saying goes, when your subroutine takes
13 arguments, you probably forgot a few.

> > > All that I am saying is that it would be handy to have a simple util
> > > that listed file names.
> > 
> > If you want to filter out directories, use grep, as several people have
> > pointed out. That's the Unix Way (tm).
> 
> But why make people use grep ( a whole to learning curve; particularly
> if you are new) when I simple option could do it for you.

Someone who uses the Unix Shell but doesn't know about grep is working
with one hand behind his back. I don't mean he needs to know all of
grep's more exotic options, but the basic usage is, well, basic.

> > 
> > >  I suggest 'ls' because it is probably the most
> > > used and first learned listing utility and therefore would be the place
> > > to have it.  It would be useful to beginners (particularly those who do
> > > not yet have any idea what a regexp is) and for script writing or piping
> > > to sed, awk, grep or a new file (or for appending).
> > 
> > Said beginners need to learn that *directories are files* (and devices
> > are files, named pipes are files, etc.). This is an important concept
> > which should not be hidden.
> 
> I don't limit my remarks to "Said beginners", I think the option would
> be useful to practised Linux users too.  But remembering the
> befuddlement, confusion and fluster I felt as a new user did bring the
> issue back to mind.

Here's another oldie: Windows is easy to learn, but Unix is easy to use.
Two entirely different things. Plus of course you have the GUI tools *as
well* these days.

> Nor do I think it is the place of any Linux distribution to decide when
> and what users should learn.  To me, that's M$ type of thinking.
> Perhaps some users can't remember as far back as when they first started
> using Linux or Unix, or perhaps they have always had an intuitive grasp
> of how computers work.

We all had to learn this stuff. IMHO the fact that it's now
second-nature to us is evidence of good design. The original Unix
designers had good taste, meaning they knew what to leave out.
Unfortunately a lot of that's been lost over the years, but the core
system is still pretty much the same. If it weren't, I'd be using a Mac.

> Or, maybe, there is just the natural old pro desire to force an
> unnecessarily onerous initiation period on beginners. 

Is it better to learn to drive with a manual or automatic gearbox? I
insist that my kids learn with a stick shift, even if they later drive
automatics, and it as nothing to do with wanting them to suffer.

> In lieu of providing an additional option to 'ls' coreutils could
> provide an 'lsf' command that would print the simple information that is
> desired.  I didn't jump into this thread because it was something I
> REALLY NEEDED, but because I thought it might be useful to others.

It's easy to write a Shell one-liner that *uses* the existing ls, and
hence has all its options as well. A separate command for this single
purpose is just teeth-gratingly wrong.

poc

-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: list files but not directory

2009-08-22 Thread William Case
On Sat, 2009-08-22 at 15:46 -0500, Mikkel L. Ellertson wrote:
> Marko Vojinovic wrote:

> > 
> > Just remember: "Do one simple thing and do i well." ;-)
> > 
> And to carry this one step farther, you can create aliases or
> function to do things you require often. For example, you could use
> something like this:
> 
> function lsp() { ls $@ && less }
> 
> so that you could run lsd instead of running "ls | less".
> 
> Mikkel

Or I could use:

]$ find . -maxdepth 1 -type f ! -name '.*'
or,
]$ find . -maxdepth 1 -type f ! -regex '^.*/\..*'
or,
]$ ls -hl | grep ^-

And I am sure there are a dozen seperate perl solutions out there!

And on and on.  Count the learning curves and side issues involved for
someone who just wants to see some text file that they wrote and saved
and that has seemed to 'disappear'.  That kind of thing happens at the
start all the time.

Let me tell you about unnecessary learning curves.  About 5 years ago,
when I installed Linux for the first time, I tentatively began to
explore the Gnome desktop and menu.  I saw Vi(m) -- a text editor.
Thinking of M$ NotePad, I opened Vim in order to make my first notes to
myself about this new operating system.  I couldn't write a word (I
didn't know about insert mode) and, determined not to solve problems by
just rebooting, it took me 4 -- let me repeat -- four hours to get out
of Vim. (Who would of thunk of escaping to normal mode and inputing a
':' to get to a command line.)

Most new users have already spent a considerable amount of time trying
to do the simplest thing before posting on users help list for the first
time out of fear of looking really really stupid.  Suggesting stuff like
"]$ find . -maxdepth 1 -type f ! -name '.*'" or  "'ls -hl | grep ^-'
just leaves their brains reeling. Particularly when they are in the
midst of trying to figure out how 10 to 20 other things work.

I will now, quietly go away.

-- 
Regards Bill
Fedora 11, Gnome 2.26.3
Evo.2.26.3, Emacs 23.1.1

-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: list files but not directory

2009-08-22 Thread Mikkel L. Ellertson
William Case wrote:
> On Sat, 2009-08-22 at 15:46 -0500, Mikkel L. Ellertson wrote:
>> And to carry this one step farther, you can create aliases or
>> function to do things you require often. For example, you could use
>> something like this:
>>
>> function lsp() { ls $@ && less }
>>
>> so that you could run lsd instead of running "ls | less".
>>
>> Mikkel
> 
> Or I could use:
> 
> ]$ find . -maxdepth 1 -type f ! -name '.*'
> or,
> ]$ find . -maxdepth 1 -type f ! -regex '^.*/\..*'
> or,
> ]$ ls -hl | grep ^-
> 
> And I am sure there are a dozen seperate perl solutions out there!
> 
Any of those would make a good function with a name that is easy to
remember so you don't have to remember the complicated command.

> And on and on.  Count the learning curves and side issues involved for
> someone who just wants to see some text file that they wrote and saved
> and that has seemed to 'disappear'.  That kind of thing happens at the
> start all the time.
> 
> Let me tell you about unnecessary learning curves.  About 5 years ago,
> when I installed Linux for the first time, I tentatively began to
> explore the Gnome desktop and menu.

God, I have been at this longer then I thought. My use of Linux
predates the Gnome desktop...

> I saw Vi(m) -- a text editor.
> Thinking of M$ NotePad, I opened Vim in order to make my first notes to
> myself about this new operating system.  I couldn't write a word (I
> didn't know about insert mode) and, determined not to solve problems by
> just rebooting, it took me 4 -- let me repeat -- four hours to get out
> of Vim. (Who would of thunk of escaping to normal mode and inputing a
> ':' to get to a command line.)
> 
Yes, you should never try to use vi for the first time without a
cheat sheet! For that matter, I normally set EDITOR so I get the
editor of my choice by default instead of vi. (Another thing new
users do not know about...)

> Most new users have already spent a considerable amount of time trying
> to do the simplest thing before posting on users help list for the first
> time out of fear of looking really really stupid.  Suggesting stuff like
> "]$ find . -maxdepth 1 -type f ! -name '.*'" or  "'ls -hl | grep ^-'
> just leaves their brains reeling. Particularly when they are in the
> midst of trying to figure out how 10 to 20 other things work.
> 
Yes, it would be better to give an explanation along with the
command. Some people do this better, and more consistently then others.

Mikkel
-- 

  Do not meddle in the affairs of dragons,
for thou art crunchy and taste good with Ketchup!



signature.asc
Description: OpenPGP digital signature
-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines

Re: list files but not directory

2009-08-23 Thread Steven W. Orr
On 08/22/09 16:46, quoth Mikkel L. Ellertson:
> Marko Vojinovic wrote:
>> There is just one thing that baffles me here --- isn't a directory also a 
>> file? 
>> Given that, what you ask for is not an option to list only files, it is an 
>> option to list everything except directories. In other words, you are asking 
>> for an option that says "list the directory contents, but omit certain 
>> things".
>>
>> The more appropriate way to do this is to use some form of filtering. Such a 
>> thing does not naturally fit into a list of options of ls, IMHO. What you 
>> actually do is perform two operations here --- list the contents, and then 
>> filter it to display only some subset. Two operations should be done using 
>> two 
>> commands, the Unix Way. And the filtering approach gives you more 
>> flexibility 
>> what file types to filter out. For example, is /dev/sda a file or a 
>> directory? 
>> How would this hypothetical ls option behave in this case? List it or not?
>>
>> There are not *just directories and files* on the system. There are
>> *just files*. And these files might be regular files, directories, devices, 
>> stdin/stdout, and who knows what else. You are proposing to add a single 
>> option to ls in order to filter out one of these types. Why only this one 
>> type? 
>> Put a whole bunch of options in ls which could list only regular files, or 
>> only 
>> character devices, or only hidden directories or... Or better yet, don't put 
>> any of that crap into ls, but pipe the ls output and filter it using a more 
>> appropriate tool.
>>
>> The completely analogous situation is with paging the output of ls. When I 
>> first used ls on a directory with lots of files, the natural idea for me was 
>> to 
>> look into its man page to find some option that would split the output into 
>> several screens and display them one by one. I failed to find such an 
>> option. 
>> After some digging, I found that this is done via a pipe to less:
>>
>> ls | less
>>
>> And then after some learning I understood that this is actually the better 
>> way 
>> to do it (more powerful, more flexible, more clean, more useful). The same 
>> situation is here with listing only non-directories. 
>>
>> The main problem is not lack of functionality, but that Windows-converts 
>> have 
>> a frame of mind that makes a distinction between "directory" and "file" 
>> concepts, and believe these concepts are fundamentally different and non-
>> overlapping. This is a Bad Idea, and it seems more appropriate to educate 
>> users than to add options to ls which make it do things it is not designed 
>> for.
>>
>> Just remember: "Do one simple thing and do i well." ;-)
>>
> And to carry this one step farther, you can create aliases or
> function to do things you require often. For example, you could use
> something like this:
> 
> function lsp() { ls $@ && less }
> 
> so that you could run lsd instead of running "ls | less".

Two things!

1. Bash syntax:
This will not work:
function lsp() { ls $@ && less }
If you do it in one line then it would have to be
function lsp() { ls $@ && less; }

If you say ls && less then you will only run the less command if the ls
command succeeds with a 0 exit status. I know this was a typo but I just
didn't want others to get confused.

*NEVER* use $@ without using double quotes. It is very bad luck and failure to
follow this advise will cause you to send 200 copies of stupid jokes to all
the people you know with aol addresses. And worse, you will end up knowing
more aol people.

What's the difference between an alias and a function? Simple: If you need to
pass arguments then use a function. I mention this because it's another of
those basic sources of confusion.

2. READ THIS BOOK!

http://catb.org/~esr/writings/taoup/

This discussion has flowed from complaining about how deficient ls is, to how
people have to learn new paradigms when moving to a new operating system. One
of the worst things that can happen to a knowledgeable Unix engineer is to
have him subjected to a windoze weenie telling how to do it right. There's a
reason that things work and work well in Unix. Do one simple thing and do it
well is really just the tip of the iceberg. In fact, Eric did a great job of
articulating enough stuff to fill an entire book of stuff that all of us
already know but may not have actually ever articulated. For example, lots of
people like C++. Lots of people like using threads. One of the cool spotlights
in the book is why you should be wary of a project that uses both.

Buy it in a book store, print out your own copy, or read it on line. No matter
how much you know, reading this is like running lsd for the first time. ;-)

-- 
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetica

Re: list files but not directory

2009-08-23 Thread William Case
On Sun, 2009-08-23 at 11:18 -0400, Steven W. Orr wrote:
> On 08/22/09 16:46, quoth Mikkel L. Ellertson:

> >> Just remember: "Do one simple thing and do i well." ;-)
> >>
> > And to carry this one step farther, you can create aliases or
> > function to do things you require often. For example, you could use
> > something like this:
> > 
> > function lsp() { ls $@ && less }
> > 
> > so that you could run lsd instead of running "ls | less".
> 
> Two things!
> 
> 1. Bash syntax:
> This will not work:
> function lsp() { ls $@ && less }
> If you do it in one line then it would have to be
> function lsp() { ls $@ && less; }
> 
> If you say ls && less then you will only run the less command if the ls
> command succeeds with a 0 exit status. I know this was a typo but I just
> didn't want others to get confused.
> 
> *NEVER* use $@ without using double quotes. It is very bad luck and failure to
> follow this advise will cause you to send 200 copies of stupid jokes to all
> the people you know with aol addresses. And worse, you will end up knowing
> more aol people.
> 
> What's the difference between an alias and a function? Simple: If you need to
> pass arguments then use a function. I mention this because it's another of
> those basic sources of confusion.
> 

After allowing that there can be "basic sources of confusion" you become
indignant that 'ls' might be a "basic sources of confusion" and are
offended -- from your engineering pedestal -- that someone should want
to discuss it.

> 2. READ THIS BOOK!
> 
> http://catb.org/~esr/writings/taoup/

Looked at it and saved the URL as a valuable reference.

> 
> This discussion has flowed from complaining about how deficient ls is, to how
> people have to learn new paradigms when moving to a new operating system. 

No one complained about how deficient 'ls'.  'ls' has been around for
years and used by millions.  However, the original poster was having
problems getting a 'clean' list of their 'regular files', a fairly
common beginner complaint.  My suggestion boiled down to, if people
expect to find such an option in 'ls' why not give it to them.

Nothing flowed anywhere.  The original poster asked how she could view
her files (i.e. regular files, text files) from the command line.  A few
suggestions followed including my suggestion that the process could be
made easier.

> One
> of the worst things that can happen to a knowledgeable Unix engineer is to
> have him subjected to a windoze weenie telling how to do it right. 

No one was telling anyone how to do anything right.  In fact, as I
re-read the thread, the posts show a tolerant and polite exchange about
why things like 'ls' are, or, are not done a certain way.  If that kind
of exchange annoys you -- ignore it and stay out of it.

To quote myself from a previous post: "Or, maybe, there is just the
natural old pro desire to force an unnecessarily onerous initiation
period on beginners." 

> There's a
> reason that things work and work well in Unix. 

That is like Dad saying "Because I said so."

> Do one simple thing and do it
> well is really just the tip of the iceberg. In fact, Eric did a great job of
> articulating enough stuff to fill an entire book of stuff that all of us
> already know but may not have actually ever articulated. For example, lots of
> people like C++. Lots of people like using threads. One of the cool spotlights
> in the book is why you should be wary of a project that uses both.
> 
> Buy it in a book store, print out your own copy, or read it on line. No matter
> how much you know, reading this is like running lsd for the first time. ;-)
> 
Thank you for the URL.

-- 
Regards Bill
Fedora 11, Gnome 2.26.3
Evo.2.26.3, Emacs 23.1.1

-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: list files but not directory

2009-08-23 Thread Mikkel L. Ellertson
Steven W. Orr wrote:
> 
> Two things!
> 
> 1. Bash syntax:
> This will not work:
> function lsp() { ls $@ && less }
> If you do it in one line then it would have to be
> function lsp() { ls $@ && less; }
> 
Yes - I did forget the ; at the end of the command. Bad morning...

> If you say ls && less then you will only run the less command if the ls
> command succeeds with a 0 exit status. I know this was a typo but I just
> didn't want others to get confused.
> 
I prefer not to have less run id ls exits with an error. That way,
if I run something like lsd *.html on a directory with no .html
files in it, I do not have to type the q to exit less.

> *NEVER* use $@ without using double quotes. It is very bad luck and failure to
> follow this advise will cause you to send 200 copies of stupid jokes to all
> the people you know with aol addresses. And worse, you will end up knowing
> more aol people.
> 
Oops - definitely a good point!

> What's the difference between an alias and a function? Simple: If you need to
> pass arguments then use a function. I mention this because it's another of
> those basic sources of confusion.
> 
I nice explanation.

Mikkel
-- 

  Do not meddle in the affairs of dragons,
for thou art crunchy and taste good with Ketchup!



signature.asc
Description: OpenPGP digital signature
-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines

Re: list files but not directory

2009-08-23 Thread ann kok


--- On Sun, 8/23/09, Mikkel L. Ellertson  wrote:

> From: Mikkel L. Ellertson 
> Subject: Re: list files but not directory
> To: "Community assistance, encouragement, and advice for using Fedora." 
> 
> Received: Sunday, August 23, 2009, 12:26 PM
> Steven W. Orr wrote:
> > 
> > Two things!
> > 
> > 1. Bash syntax:
> > This will not work:
> > function lsp() { ls $@ && less }
> > If you do it in one line then it would have to be
> > function lsp() { ls $@ && less; }
> > 
> Yes - I did forget the ; at the end of the command. Bad
> morning...
> 
> > If you say ls && less then you will only run
> the less command if the ls
> > command succeeds with a 0 exit status. I know this was
> a typo but I just
> > didn't want others to get confused.
> > 
> I prefer not to have less run id ls exits with an error.
> That way,
> if I run something like lsd *.html on a directory with no
> .html


Why I can't run lsd?
Do I need to install any package?

-bash: lsd: command not found










> files in it, I do not have to type the q to exit less.
> 
> > *NEVER* use $@ without using double quotes. It is very
> bad luck and failure to
> > follow this advise will cause you to send 200 copies
> of stupid jokes to all
> > the people you know with aol addresses. And worse, you
> will end up knowing
> > more aol people.
> > 
> Oops - definitely a good point!
> 
> > What's the difference between an alias and a function?
> Simple: If you need to
> > pass arguments then use a function. I mention this
> because it's another of
> > those basic sources of confusion.
> > 
> I nice explanation.
> 
> Mikkel
> -- 
> 
>   Do not meddle in the affairs of dragons,
> for thou art crunchy and taste good with Ketchup!
> 
> 
> -Inline Attachment Follows-
> 
> -- 
> fedora-list mailing list
> fedora-list@redhat.com
> To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
> Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


  __
Ask a question on any topic and get answers from real people. Go to Yahoo! 
Answers and share what you know at http://ca.answers.yahoo.com

-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: list files but not directory

2009-08-23 Thread ann kok

> > 
> > ]$ find . -maxdepth 1 -type f ! -name '.*'
> > or,
> > ]$ find . -maxdepth 1 -type f ! -regex '^.*/\..*'
> > or,
> > ]$ ls -hl | grep ^-
> > 

This works fine 
but there is ./file as result
How can remove ./ in the command also?

 










> > And I am sure there are a dozen seperate perl
> solutions out there!
> > 
> Any of those would make a good function with a name that is
> easy to
> remember so you don't have to remember the complicated
> command.
> 
> > And on and on.  Count the learning curves and
> side issues involved for
> > someone who just wants to see some text file that they
> wrote and saved
> > and that has seemed to 'disappear'.  That kind of
> thing happens at the
> > start all the time.
> > 
> > Let me tell you about unnecessary learning
> curves.  About 5 years ago,
> > when I installed Linux for the first time, I
> tentatively began to
> > explore the Gnome desktop and menu.
> 
> God, I have been at this longer then I thought. My use of
> Linux
> predates the Gnome desktop...
> 
> > I saw Vi(m) -- a text editor.
> > Thinking of M$ NotePad, I opened Vim in order to make
> my first notes to
> > myself about this new operating system.  I
> couldn't write a word (I
> > didn't know about insert mode) and, determined not to
> solve problems by
> > just rebooting, it took me 4 -- let me repeat -- four
> hours to get out
> > of Vim. (Who would of thunk of escaping to normal mode
> and inputing a
> > ':' to get to a command line.)
> > 
> Yes, you should never try to use vi for the first time
> without a
> cheat sheet! For that matter, I normally set EDITOR so I
> get the
> editor of my choice by default instead of vi. (Another
> thing new
> users do not know about...)
> 
> > Most new users have already spent a considerable
> amount of time trying
> > to do the simplest thing before posting on users help
> list for the first
> > time out of fear of looking really really
> stupid.  Suggesting stuff like
> > "]$ find . -maxdepth 1 -type f ! -name '.*'" or 
> "'ls -hl | grep ^-'
> > just leaves their brains reeling. Particularly when
> they are in the
> > midst of trying to figure out how 10 to 20 other
> things work.
> > 
> Yes, it would be better to give an explanation along with
> the
> command. Some people do this better, and more consistently
> then others.
> 
> Mikkel
> -- 
> 
>   Do not meddle in the affairs of dragons,
> for thou art crunchy and taste good with Ketchup!
> 
> 
> -Inline Attachment Follows-
> 
> -- 
> fedora-list mailing list
> fedora-list@redhat.com
> To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
> Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


  __
Looking for the perfect gift? Give the gift of Flickr! 

http://www.flickr.com/gift/

-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: list files but not directory

2009-08-23 Thread William Case
Hi Ann;

On Sun, 2009-08-23 at 12:07 -0700, ann kok wrote:
> > > 
> > > ]$ find . -maxdepth 1 -type f ! -name '.*'
> > > or,
> > > ]$ find . -maxdepth 1 -type f ! -regex '^.*/\..*'
> > > or,
> > > ]$ ls -hl | grep ^-
> > > 
> 
> This works fine 
> but there is ./file as result
> How can remove ./ in the command also?
> 

The './' is the name of the current directory where the files are
located.  If you prefer not to see it, use:

]$ find . -maxdepth 1 -type f ! -name '.*' -exec basename {} \;
]$ find . -maxdepth 1 -type f ! -regex '^.*/\..*' -exec basename {} \;

exactly as written here.

-- 
Regards Bill
Fedora 11, Gnome 2.26.3
Evo.2.26.3, Emacs 23.1.1

-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: list files but not directory

2009-08-23 Thread Cameron Simpson
On 21Aug2009 05:17, ann kok  wrote:
| ls -1 but I only want the file to list not directory

Please don't top-post. PLease BELOW and TRIM the quoted material for
context, as I have done.

Have you tried:

  ls -l | grep '^-'

Cheers,
-- 
Cameron Simpson  DoD#743
http://www.cskk.ezoshosting.com/cs/

War doesn't prove who's right, only who's left. - BDD Games' Fortune

-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: list files but not directory

2009-08-23 Thread Sharpe, Sam J
2009/8/23 Cameron Simpson :
> On 21Aug2009 05:17, ann kok  wrote:
> | ls -1 but I only want the file to list not directory
>
> Please don't top-post. PLease BELOW and TRIM the quoted material for
> context, as I have done.
>
> Have you tried:
>
>  ls -l | grep '^-'

I don't understand why this thread has been going on so long. I also
can't understand how the OP couldn't solve this with a quick {insert
web search engine of your choice} query.

alias lsf='find . -maxdepth 1 -type f -ls'
alias lsd='find . -maxdepth 1 -type d -ls'

-- 
Sam

-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: list files but not directory

2009-08-25 Thread Bryn M. Reeves
On Fri, 2009-08-21 at 17:09 +0400, Hiisi wrote:
> > Hi
> >
> > any way to list files but not directory
> >
> > Thank you
> >
> 
> ls -hl | grep ^-

Lists things that aren't regular files.

Bryn.


-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: list files but not directory

2009-08-25 Thread Marcelo M. Garcia

Bryn M. Reeves wrote:

On Fri, 2009-08-21 at 17:09 +0400, Hiisi wrote:

Hi

any way to list files but not directory

Thank you


ls -hl | grep ^-


Lists things that aren't regular files.

Bryn.



Hi

find /path/to/dir -type f -print

Regards

mg.

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: list files but not directory

2009-08-25 Thread Cameron Simpson
On 25Aug2009 10:41, Bryn M. Reeves  wrote:
| On Fri, 2009-08-21 at 17:09 +0400, Hiisi wrote:
| > > any way to list files but not directory
| > 
| > ls -hl | grep ^-
| 
| Lists things that aren't regular files.

No, it lists things that _are_ regular files. You confusing it with
this:

  ls -hl | grep '^[^-]'

Cheers,
-- 
Cameron Simpson  DoD#743
http://www.cskk.ezoshosting.com/cs/

We now return you to the previously scheduled counter-steering flame-fest
and under-clothing auction, after a few words about your sponsor, the DoD.
- Denis McKeon 

-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines