LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1140|回复: 7

"find /new_dir -exec grep -l old_dir {} \;"该命令查了手册,

[复制链接]
发表于 2005-8-15 22:49:11 | 显示全部楼层 |阅读模式
unix技术大全--系统管理员卷 说此命令发现新目录中没有而在旧目录中存在的文件,还将发现的新文件移到新目录中.同时将HOME变量的绝对路径名改变.

我在网上查了许久,都不能理解,请高手讲解一下!

下面的命令,我能理解
find / -user username -exec rm {} \;
发表于 2005-8-15 22:57:06 | 显示全部楼层
我也不懂
回复 支持 反对

使用道具 举报

发表于 2005-8-16 18:44:32 | 显示全部楼层
{}中存放着find的结果,\;不过是必要的格式
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-8-17 08:29:43 | 显示全部楼层
谢谢楼上的回复。
grep -l 有移动文件的作用?还能改变将HOME变量的绝对路径名?
回复 支持 反对

使用道具 举报

发表于 2005-8-17 10:14:24 | 显示全部楼层
Post by newred
谢谢楼上的回复。
grep -l 有移动文件的作用?还能改变将HOME变量的绝对路径名?

grep有那些个功能吗?-l 只表示列出文件名,哪来什么移动文件和改变路径啊。你的命令灭有抄漏吧。。?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-8-18 19:46:20 | 显示全部楼层
这就是我不理解的,难道是中文版书翻译错了?

网上没有中文版,这是英文版内容,书名是"UNIX Unleashed, System Administrator's Edition"

---------------------------------
If the home directory of a username is altered, the previous initial directory files must be moved to the new directory. To move a user directory, issue the command:

cd /old_dir; tar -cf - . | (cd /new_dir; tar -xpf -)

Verify the result and then remove old_dir. If the user base is not entirely knowledgeable, look for old_dir in existing files and change them to new_dir for the user. The system can locate any entries by:

find /new_dir -exec grep -l old_dir {} \;

For any entries that find locates, change the entry to new_dir or, when appropriate, change the absolute path name to the more generic $HOME variable. Pay particular attention to the start up (dot) files contained within a user's home directory because errors in that class of file will surely get the attention of a user quickly.
-----------------------------------
网页地址:http://docs.rinet.ru:8080/UNIXs/ch17.htm
回复 支持 反对

使用道具 举报

发表于 2005-8-18 22:15:49 | 显示全部楼层
Post by newred
这就是我不理解的,难道是中文版书翻译错了?

网上没有中文版,这是英文版内容,书名是"UNIX Unleashed, System Administrator's Edition"

---------------------------------
If the home directory of a username is altered, the previous initial directory files must be moved to the new directory. To move a user directory, issue the command:

cd /old_dir; tar -cf - . | (cd /new_dir; tar -xpf -)

Verify the result and then remove old_dir. If the user base is not entirely knowledgeable, look for old_dir in existing files and change them to new_dir for the user. The system can locate any entries by:

find /new_dir -exec grep -l old_dir {} \;

For any entries that find locates, change the entry to new_dir or, when appropriate, change the absolute path name to the more generic $HOME variable. Pay particular attention to the start up (dot) files contained within a user's home directory because errors in that class of file will surely get the attention of a user quickly.
-----------------------------------
网页地址:http://docs.rinet.ru:8080/UNIXs/ch17.htm


ok, 我的理解,英文对于find的命令的作用只有一句,就是"The system can locate any entries by". 其他的事都得用户自己做。"For any entries that find locates",这一句可以证明,find除了locate entries,再没做别的。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-8-19 21:22:41 | 显示全部楼层
非常感谢! 书上确实是翻译错了.
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表