Hacker News new | past | comments | ask | show | jobs | submit login

You need a separate command with options and a flag to do that in bash.

No you don't; whether ls is a builtin is mostly irrelevant, but

    ls *1*.png
does exactly what you (I assume) are saying,

    dir *1*.png
which AFAIK is a new extension introduced with WinNT's command processor, since the old algorithm...

https://blogs.msdn.microsoft.com/oldnewthing/20071217-00/?p=...

...would effectively produce a pattern matching all files ending in '.png'.




This use of the word "new" is a bit of a stretch. Consider that the "new" wildcard algorithm has been around for as long as Linux has. Possibly longer, although I'd have to check when 4DOS and 4OS2 started providing extended wildcards.


using ls with globbing is redundant: the shell will expand * 1* .png to a list of files, which will then be passed to the argument vector of ls, looking up the files twice. You could just do echo * 1* .png.

ls doesn't do glob matching. ls '*' would try to fstatat (FreeBSD) that character.

EDIT: formatting




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: