How do I make an alias
in .bashrc
with sub-commands?
Right now I have:
alias pngc="for file in \`find \$1 -name \"*.png\"\`; do pngcrush -brute \"\$file\" temp.png; mv -f temp.png \$file; done"
If I enter this in a shell, the alias is registered correctly and I can run it correctly. However, if I add this to .bashrc
, (parts of) it runs at login, which I know because it hangs for a huge amount of time, probably because it's find
-ing in my entire home directory.
(Not a duplicate of this or that)
Edits based on comments:
Attempt:
alias pngc="for file in ./*.png; do pngcrush -brute \"\$file\" temp.png; mv -f temp.png \$file; done"
Could not find file: ./*.png
Could not find file: temp.png
(temp
is the current directory)
Attempt:
alias pngc="for file in ./*.png; do [[ -f \"\$i\" ]] || continue; pngcrush -brute \"\$file\" temp.png; mv -f temp.png \$file; done"
Does nothing!
0 Answers