5 ms·
I think this is what you are looking for $ find ./tmp -maxdepth 1 -type f -printf '%f\n'
by fooblat 6y ago
I think this is what you are looking for
$ find ./tmp -maxdepth 1 -type f -printf '%f\n'
- rmetzler 6y agoI'm on MacOS... :-/ $ find ./tmp -maxdepth 1 -type f -printf '%f\n' find: -printf: unknown primary or operator
- fooblat 6y agoIf you use brew or macports you can install the coreutils package and then you're good to go with gnu find. I also use MacOS and I have setup the gnu userland on my local so it matches the linux environment on our servers and containers.
- gpanders 6y agoYou’re right that defaulting to the GNU coreutils is probably more convenient. However, NOT doing this is a good way to ensure that any scripts you write remain portable and don’t use GNU extensions. That’s the reason I stick with the default BSD coreutils on macOS.
- fooblat 6y ago> You’re right that defaulting to the GNU coreutils is probably more convenient. It's not about convenience. It is about having a development environment that matches the target runtime environment. You can run into nasty surprises when the default behavior of a tool in your dev environment is different than in your production environment. I've been writing shell scripts professionally for over 20 years and I have always taken this approach and it has served me well.
- saagarjha 6y agoYou could also try restricting yourself to POSIX shell.
- Normille 6y agofind <directory path> -type f -d 1 Works for me on OSX.
- pbhjpbhj 6y agoNot got a shell handy, but "-exec ls"?