for x in *.png;
do
fn=`basename "${x}" .png | sed 's/ /\\ /g'`
convert "${fn}.png" "${fn}.jpg"
done
Showing posts with label bash. Show all posts
Showing posts with label bash. Show all posts
Friday, March 2, 2012
Filenames with spaces in bash
Friday, February 3, 2012
Multiple Comparison in Bash
Checking multiple conditions in Bash can be tricky.
Following require
This post is a nice concise resource.
Following require
STRING1
and STRING2
to be not empty and COUNTER < MAX
.
if [[ -n "$STRING1" && -n "$STRING2" && $COUNTER -lt $MAX ]];
then
...
fi
This post is a nice concise resource.
Thursday, February 2, 2012
Apply Commands Only to All Files or Directories
Choose "type" to be "d" (directory) or "f" (file).
More generally, any "command" will work, too.
find . -type "type" -exec chmod 755 {} \;
find . -type "type" -exec chown owner.group {} \;
More generally, any "command" will work, too.
find . -type "type" -exec "command" {} \;
Wednesday, February 1, 2012
Running Commands in a Sub-shell
Content is from this post
Here is how to run "/bin/script.sh" inside "/workingdir" without changing your current path.
Here is how to run sequence of commands with checking status after each command by inserting "&&"
Memory is better managed by using "exec" command.
Here is how to run "/bin/script.sh" inside "/workingdir" without changing your current path.
(cd /workingdir; /bin/script.sh)
Here is how to run sequence of commands with checking status after each command by inserting "&&"
(cd /workingdir && /bin/script.sh)
Memory is better managed by using "exec" command.
(cd /workingdir && exec /bin/script.sh)
Subscribe to:
Posts (Atom)