News for hackers. Stuff that matters.
Re:Useful command-line scripts for web developers (or anyone... by greyboy on Friday June 05, 2009 @01:24PM (#643564)
Am I missing something? What's wrong with:

  $ ls *5*
??

The find command is more powerful (descending into subdirs, etc.), but the original example in the link only specified the current directory.

Re:Useful command-line scripts for web developers (or anyone... by prodigal_erik on Friday June 05, 2009 @02:41PM (#643698)
I have used production batch processing systems that routinely store enough files that

  ls *5*
will fail because the argument list was too big for execve(2). Would I design it that way? No, but people do (sometimes without really thinking about it), and you still have to get work done.

New users should be taught find(1) because it always works.

Re:Useful command-line scripts for web developers (or anyone... by greyboy on Friday June 05, 2009 @05:23PM (#644025)
Right, I understand the problem. Find and xargs can do wonders. However, that's usually an edge case (in my professional experience). I'm certainly not proclaiming the advanced-ness of 'ls' in this circumstance.

However, in the example in the article, he was using "ls" piped to "grep" in order to find all files with a 5 in the name. That would suffer from the same consequences you mentioned, on such systems, and is inefficient and verbose.

Note, I agree with your advice to teach "find" (and "xargs") to users.

Re:Useful command-line scripts for web developers (or anyone... by prodigal_erik on Saturday June 06, 2009 @07:21PM (#645254)
True,

  ls | grep 5
is reliable where

  ls *5*
is not. (Well, except for awful names that require "find -print0", or preferably having the file taken out and shot along with its creator.)

I'm actually not a fan of xargs. It's more unixy, but somehow I find its options hard to remember. Off the top of my head I find it easier to do

  find -exec blah {} +
Re:Useful command-line scripts for web developers (or anyone... by nuclear_eclipse on Friday June 05, 2009 @01:42PM (#643599)
Sorry, I got so caught up the frustration that I forget to post that as my real frustration. :P That was exactly what I first thought when I saw that, and was posting the `find` calls as just a easier / more comprehensive method of looking, esp when you start wanting recursive searches. The fact that you can add tons of different search filters to `find` that you can't have with `ls` really make it the goto way of finding files, rather than piping ls to some form of grep or whatnot.
Re:Useful command-line scripts for web developers (or anyone... by philh on Friday June 05, 2009 @02:26PM (#643665)

    $ ls -d *5*
Otherwise you get a listing of any directory with a 5 in the name.