我有一个带文件名列表的txt文件,其中包含文件路径。如何将所有文件连接到单个文件?
EX:
One.txt content >> first file content
two.txt content >> second file content
three.txt content >> third file content
allFiles.txt contains these the below lines
one.txt
two.txt
three.txt
我需要将allFiles.txt连接到包含以下行的output.txt文件
first file content
second file content
third file content
答案 0 :(得分:0)
while read fname
do
sed '1' "$fname" >> newfile.txt # You need to append so '>>'
done<allFiles.txt
但是如果您需要所有*.txt
个文件
可以像
一样简单shopt -s globstar
sed '' **/*.txt 1>>/outfile 2>/dev/null # errors for .txt directories are suppressed
shopt -u globstar