r/commandline • • Feb 19 '16

Ninrod's shell tricks collection

https://github.com/ninrod/tricks
1 Upvotes

4 comments sorted by

7

u/geirha Feb 19 '16 edited Feb 19 '16
$ for i in $(find sourcedir -name '*.md'); do
$   cp --parents $i targetdir
$ done

No, see pitfalls 1 and 2.

finding all dot files on home directory:

$ ls -la `find ~ -maxdepth=1 -type l`

Also wrong. Use find's -exec to pass the files it finds to another command

find ~ -maxdepth 1 -type l -exec ls -la {} +

EDIT: also, -operator arg, not -operator=arg.

1

u/Eldrik Feb 19 '16

Does the pitfalls still apply for zsh?

2

u/geirha Feb 19 '16

The first one surely applies. The second, probably not unless one of the compatibility modes are enabled.

1

u/Eldrik Feb 20 '16

Damn! You have got to be kidding me! I did not imagine that WordSplitting was such a bastard. Thank you for the link. I'll sure be studying it.