is just a synonym for ls
. They're the same command. The parsingls link I gave above applies to grepping it as well. i.e. it won't correctly handle filenames that include embedded newlines.
In addition, you'd need to use the -1
option ("one", not "ell") to get the output in one-file-per-line order before grep
could work on it correctly, and grep
uses regular expressions
for pattern matching, not globbing.
ls -1 | grep '-3001-'
Unlike globs, which have to match the entire string, regexes are unbounded by default. They can match a substring anywhere on the line. So just using the fixed text alone will do the job (fixed text strings count as proper regex patterns).
For what it's worth though, the regex version of '*
' is '.*
', so this is equivalent:
ls -1 | grep '.*-3001-.*'
Finally, you need to use backslashes to escape reserved characters, not forward slashes. Quotes are usually easier to read though.