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", indicate find command find files name matches pattern *.dwp, ignore case, e.g.: ./a.dwp
  • -exec expression {} \; part, execute command bash -c 'mv "$0" "${0%\.dwp}.html"' {}. {} replaced path of each file. expression terminated semicolon. if there file a.dwp in current directory, bash -c 'mv "$0" "${0%\.dwp}.html"' a.dwp execute.

    bash -c 'mv "$0" "${0%\.dwp}.html"' {}: 
    • -c means read command string, not start interactive shell.
    • $0 argument of command, a.dwp in example.
    • ${0%\.dwp}.html string manipulation, % removes shortest match end, a.dwp, remove .dwp end file name a without extension.

    so command mv a.dwp a.html.

the second 1 simple if understand first one.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -