Если ваши изображения были названы несколько иначе, например:
images/147615000-000.jpg
images/147615000-001.jpg
... more images ...
images/147615000-090.jpg
Тогда вы можете сделать это:
convert -delay 10 -loop 0 images/147615000-*.jpg animation.gif
Но я предполагаю, что изображения имеют временную метку по какой-то причине.
Вы можете попробовать что-то вроде этого сценария:
#!/bin/sh
#
# Find images from $1 to $2 inclusive
if [ "$2" = "" ]
then
echo "Pass the first and last file."
exit
fi
# Basic file check
if [ ! -f "$1" ]
then
echo "$1 not found."
exit
fi
if [ ! -f "$2" ]
then
echo "$2 not found."
exit
fi
# Get the file list. Note: This will skip the first file.
list=`find "./" -type f -newer "${1}" -and -type f -not -newer "${2}"`
# Include the first image
list="./$1
$list"
# Sort the images as find may have them in any order
list=`echo "$list" | sort`
# create the animation.gif
convert -delay 10 -loop 0 $list animation.gif
# say something
echo "Done"
Поместите этот сценарий в каталог, который вы хотите создать, «animation.gif», и я предполагаю, что изображения находятся в подкаталоге. Вы бы назвали его так:
sh ./fromToAnimation.sh images/147615000.jpg images/1476162527.jpg
Это будет работать до тех пор, пока в именах файлов или пути нет пробелов или других специальных символов.
Чтобы избежать использования eval
:
opt_file=""
# Command line parsing bit here, setting opt_file to a
# file name given by the user, or leaving it empty.
if [[ -z "$opt_file" ]]; then
outfile="/dev/stdout"
else
outfile="$opt_file"
fi
exec echo hi >>"$outfile"
Немного более короткий вариант, который делает то же самое:
# (code that sets $opt_out to a filename, or not,
# and then...)
outfile=${opt_file:-/dev/stdout}
exec echo hi >>"$outfile"
Я думаю, что единственный способ сделать это - использовать eval
, и все классические предостережения о eval
будут применимы. Тем не менее, вы можете сделать что-то вроде этого:
REDIRECT=">>test"
eval echo hi ${REDIRECT}
Вы можете перенаправить весь stdout
в файл с помощью команды exec
{{ 1}} например,
exec >> outfile
Теперь любой вывод будет отправлен в Outfile
.
Например:
#!/bin/bash
exec >> outfile
echo start
echo hello
echo there
echo end
Если мы запустим это:
$ ./x
$ cat outfile
start
hello
there
end
$ ./x
$ cat outfile
start
hello
there
end
start
hello
there
end
Итак, мы можем видеть, что каждое выполнение добавляется.
Это становится просто добавить в тесте
if [ -n "$REDIRECT" ]
then
exec >> $REDIRECT
fi