2016-03-03 61 views
0

我有一个文本文件“modules.txt”含有(单独的模块名):终端的mkdir

dashboard 
editor 
images 
inspector 
loader 
navigation 
sharing 
tags 
toolbar 

欲像每个模块创建文件夹结构:

dashboard/templates 
editor/templates 
flash/templates 
images/templates 

cat modules.txt | xargs mkdir -p $1/templates 
0:

等等

我在的区域摆弄周围

但是这将创建文件夹的第一级,忽略/模板的一部分,并给予与错误:

mkdir: /templates: File exists 

它不。

我已经尝试了所有种类的组合:

cat modules.txt | xargs mkdir -p $1/{templates} 
cat modules.txt | xargs mkdir -p $1{templates} 
cat modules.txt | xargs mkdir -p $1/{templates} 
cat modules.txt | xargs mkdir -p $1\/{templates} 

(是的,相当多的猜测这里)

我也试着到/模板添加到每一行的文本文件,但这会让整个事情崩溃。

任何想法如何去做到这一点?

回答

0

原来,在向文本文件中添加/模板时,这起作用。当摆弄这件事时,一定是累了(或者愚蠢)。

cat file_containing_folder_structure.txt | xargs mkdir -p