如何治疗2目录为一体,在命令行 [英] How to treat 2 Directories as one in the command line

查看:127
本文介绍了如何治疗2目录为一体,在命令行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个脚本,这需要目录的列表,并比较它们的文件的数量。我想是有时组的两个或多个目录中被视为一个由脚本。当然,我可以修改脚本,但我会preFER做这个分组中的命令行。

I have a script, which takes a list of directories and compares their number of files. What I would like is to sometimes group two or more directories to be treated as one by the script. Of course I could modify the script but I would prefer to do this grouping in the command line.

$ ./myscript.sh {dir1 dir2} dir3 dir4 ... 

应该被视为犹如{DIR1 DIR2}是两个目录的元素(数学)的结合。

should be treated as if {dir1 dir2} was the (mathematical) union of the elements of both directories.

如何实现这一点?

推荐答案

怎么样在一个单独的脚本合并目录内容一起,然后通过该脚本作为参数:

How about merging the directory contents together in a separate script, and then passing that script as a parameter:

file1=$1
file2=$2
cp -R $file1/* $file2
echo $file2

然后就可以使用脚本如下:

Then you can use the script as follows:

./myscript "$(./merge dir1 dir2)" dir3 ...

这篇关于如何治疗2目录为一体,在命令行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆