unix命令复制具有已修改目录结构的所有.h文件 [英] unix command to copy all .h file with modified directory-structure
本文介绍了unix命令复制具有已修改目录结构的所有.h文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我有一个类似的文件夹结构:
Suppose I have a folder structure like:
图书馆\
- UIToolkit \
- 文件\
- toolkit.h
- toolkit.c
- toolkit.resource
- 文件\
- network.h
- network-info.txt
...
我需要一个命令,以便我可以输入Libraries文件夹并指定一个Output文件夹,然后在Output文件夹中拥有:
I need a command so that I can input the Libraries folder and specify a Output folder then in the Output folder I have:
输出\
- UIToolkit \
- toolkit.h
- network.h
基本上是这样:
- 复制所有.h文件并保留文件夹结构
- 还将所有标题移到其子库的根文件夹中,无论它们在子库子文件夹中有多深.
我正在使用rsync,但是它没有执行第二步,所以我想我需要进行一些快速而肮脏的修改吗?
I was using rsync but it does not do 2nd step, so I guess I need some quick and dirty modification?
非常感谢!
推荐答案
您可以说:
cd /path/to/Libraries while read -r file; do odir=$(cut -d'/' -f2 <<< ${file}); fname=$(basename ${file}); cp "$file" "/path/to/Output/${odir}/${fname}"; done < <(find . -type f -name "*.h")
这将根据所需的目录结构将所有
*.h
文件复制到Output
文件夹中.This would copy all the
*.h
files to theOutput
folder as per the desired directory structure.这篇关于unix命令复制具有已修改目录结构的所有.h文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
- 文件\
查看全文