2
0
mirror of https://github.com/chubin/cheat.sheets synced 2024-11-19 03:25:44 +00:00

Wildcards (*) should always be in single quotes

Otherwise bash might expand with if matches are found
This commit is contained in:
Martin Westergaard Lassen 2019-08-01 14:19:46 +02:00 committed by GitHub
parent b01259c674
commit 474823fbd7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,5 @@
# To find files by case-insensitive extension (ex: .jpg, .JPG, .jpG): # To find files by case-insensitive extension (ex: .jpg, .JPG, .jpG):
find . -iname "*.jpg" find . -iname '*.jpg'
# To find directories: # To find directories:
find . -type d find . -type d
@ -51,4 +51,4 @@ find . -type f -exec chmod 644 {} \;
find . -iname '*.txt' -exec vim {} \+ find . -iname '*.txt' -exec vim {} \+
# To find all files with extension '.png' and rename them by changing extension to '.jpg' (base name is preserved) # To find all files with extension '.png' and rename them by changing extension to '.jpg' (base name is preserved)
find . -type f -iname "*.png" -exec bash -c 'mv "$0" "${0%.*}.jpg"' {} \; find . -type f -iname '*.png' -exec bash -c 'mv "$0" "${0%.*}.jpg"' {} \;