我有以下脚本:
#!/bin/sh
HOST='host'
USER='user@example.com'
PASSWD='pwd'
for FILE in *.avi
do
ftp -n $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
binary
put $FILE
rm FILE
quit
done
END_SCRIPT
exit 0
如何确保首先处理最早的文件?我已经看到很多使用ls -t的技巧,但是必须有一种更简单的方法。
答案 0 :(得分:0)
我会用以下方法修改您的for
循环:
for FILE in `ls -tU *.avi`
do
#
# loop content here with ${FILE}
#
done
来自ls
文档:
-t Sort by time modified (most recently modified first) before
sorting the operands by lexicographical order.
-U Use time of file creation, instead of last modification for
sorting (-t) or long output (-l).