Chinaunix

标题: find后-ecex多命令顺序执行的问题 [打印本页]

作者: authen    时间: 2005-05-21 14:48
标题: find后-ecex多命令顺序执行的问题
目的:找到某目录下test文件后修改日期为2005年01月01日01时01秒,然后将其拷贝到/teczm下:

现在能做到:
%find . -type f -name "test" -exec touch -t 0501010101 {} \;
但不能一步完成目的操作。

试了:
%find . -type f -name "test" -exec touch -t 0501010101 {} \;;mv {} /teczm \;

返回出错。

how to  
作者: 寂寞烈火    时间: 2005-05-21 15:16
标题: find后-ecex多命令顺序执行的问题
try:

  1. ls test|while read file;do
  2. touch -t 0501010101 $file
  3. done
复制代码

作者: icesummit    时间: 2005-05-21 17:44
标题: find后-ecex多命令顺序执行的问题
try:

$ find . -type f -name "test" -exec touch -t 0501010101 {} \; -exec mv {} /teczm  \;
作者: zleil    时间: 2005-05-22 15:55
标题: find后-ecex多命令顺序执行的问题
%find . -type f -name "test" -exec touch -t 0501010101 {} \;;mv {} /teczm \;
                                                                                 \;;多写了一个冒号
作者: authen    时间: 2005-05-23 08:23
标题: find后-ecex多命令顺序执行的问题
原帖由 "icesummit"]$ find . -type f -name "test" -exec touch -t 0501010101 {} \; -exec mv {} /teczm  \;[/quote 发表:

谢谢

[quote]原帖由 "寂寞烈火" 发表:
ls test|while read file;do
touch -t 0501010101 $file
done

不是很明白,$file==引用变量?但是,在那里赋予了这个变量呢?
作者: 寂寞烈火    时间: 2005-05-23 10:19
标题: find后-ecex多命令顺序执行的问题
while read用于逐行读取, $file就是每行的内容




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2