Unix的脚本来查找目录中的所有文件夹 [英] Unix script to find all folders in the directory
问题描述
基本上我需要运行一个Unix脚本来查找目录中的所有文件夹/ FSS /鳍,如果它存在;然后,我有焦油并移动到另一个目录/ FS /网络连接。
这是我的命令为止:
查找/ FSS /鳍型ð-nameEssbase的-print
在这里,我所提到的文件夹名称的Essbase,而不是说我一定要找到在/ FSS的所有文件夹/鳍。
如何找到在/ FSS / FIN目录和功放的所有文件夹;焦油它移到/ FS / FI?
澄清1:
是的,我需要使用的Unix shell脚本查找目录/ FSS / FIN目录只是所有文件夹和其焦油到另一个目录/ FS /网络连接。
块引用>澄清2:
我想让它与要求明确。 Shell脚本应包含:
- 找到目录中的所有文件夹/ FSS / FIN
- 焦油的文件夹
- 将文件夹中的另一个目录/ FS / FI这在服务器s11003232sz.net
- 当用户请求解压的文件夹并将其移动回一部开拓创新目录/ FSS / FIN
块引用>解决方案下面是一个例子,我与工作可能会导致你在正确的方向
BACKUPDIR =/ SRV /备份/
SrvDir =/ SRV /网络/
日期戳= $(日期+%Y%M%D);对目录中的$(找到$ SrvDir * -maxdepth 0型D);
做
文件夹名称= $($基名DIR);
焦油ZCF$ BACKUPDIR $日期戳。$ FolderName.tar.gz-P $迪尔
DONEBasically I need to run a Unix script to find all folders in the directory /fss/fin, if it exists; then I have tar it and move to another directory /fs/fi.
This is my command so far:
find /fss/fin -type d -name "essbase" -print
Here I have mentioned folder name essbase instead of that I have to find all the folder in the /fss/fin.
How to find all folders in the /fss/fin directory & tar it to move to /fs/fi?
Clarification 1:
Yes I need to find only all folders in directory /fss/fin directory using Unix shell script and tar it to another directory /fs/fi.
Clarification 2:
I want to make it clear with the requirement. The Shell Script should contain:
- Find all the folders in the directory /fss/fin
- Tar the Folders
- Move the folders in another directory /fs/fi which in server s11003232sz.net
- When user requests untar the Folders and move it back to the orignal directory /fss/fin
解决方案here is an example I am working with that may lead you in the correct direction
BackUpDIR="/srv/backup/" SrvDir="/srv/www/" DateStamp=$(date +"%Y%m%d"); for Dir in $(find $SrvDir* -maxdepth 0 -type d ); do FolderName=$(basename $Dir); tar zcf "$BackUpDIR$DateStamp.$FolderName.tar.gz" -P $Dir done
这篇关于Unix的脚本来查找目录中的所有文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!