我想写个脚本将某个文件夹下面出现的pdf文件全部移动到某个地点,、
for filename in $tempfile
do
if test -e .*pdf
then
mv filename ./doc/
tempfile 保存有当前文件夹下的文件列表,但是test哪一行有问题,字符串比较不对呀,望各位指教
字符串比较的问题
- xiooli
- 帖子: 6956
- 注册时间: 2007-11-19 21:51
- 来自: 成都
- 联系:
Re: 字符串比较的问题
代码: 全选
find your_dir -name "*pdf" -exec mv {} another_dir \;
-
- 帖子: 28
- 注册时间: 2007-10-19 18:29
Re: 字符串比较的问题
明白你的意思,我还是想搞清楚为什么我写的那个字符串比较不对呢?
ps:因为下载的东西都在一个文件夹下,所以很乱,想写个脚本,用cron来做的,将文件归类以下,没写过脚本,望指教了
ps:因为下载的东西都在一个文件夹下,所以很乱,想写个脚本,用cron来做的,将文件归类以下,没写过脚本,望指教了
-
- 帖子: 28
- 注册时间: 2007-10-19 18:29
Re: 字符串比较的问题
改成了:
for filename in $tempfile
do
if [ $filename == "*.pdf" ]
then
mv $filename ./doc
还是不对呀!
for filename in $tempfile
do
if [ $filename == "*.pdf" ]
then
mv $filename ./doc
还是不对呀!
-
- 帖子: 28
- 注册时间: 2007-10-19 18:29
Re: 字符串比较的问题
改成 if [[ $filename == *pdf ]]对了,。。。。。。。。。。。。。。。。



