Interpret bash commands -
i checked resources, still hard find clue interpret codes.
$ find . -iname "*.dwp" -exec bash -c 'mv "$0" "${0%\.dwp}.html"' {} \;
$ find . -name ".ds_store" -exec rm {} \;
to more specific, what's difference between -iname , -name? , "-c" , "%" symbolize?
can interpret 2 commands bit me?
the first one:
-iname "*.dwp", indicatefindcommand find files name matches pattern*.dwp, ignore case, e.g.:./a.dwp-exec expression {} \;part, execute commandbash -c 'mv "$0" "${0%\.dwp}.html"' {}.{}replaced path of each file. expression terminated semicolon. if there filea.dwpin current directory,bash -c 'mv "$0" "${0%\.dwp}.html"' a.dwpexecute.bash -c 'mv "$0" "${0%\.dwp}.html"' {}:-cmeans read command string, not start interactive shell.$0argument of command,a.dwpin example.${0%\.dwp}.htmlstring manipulation,%removes shortest match end,a.dwp, remove.dwpend file nameawithout extension.
so command
mv a.dwp a.html.
the second 1 simple if understand first one.
Comments
Post a Comment