如何从Bash中的文件列表中隐藏多个文件? [英] How to cat multiple files from a list of files in Bash?
本文介绍了如何从Bash中的文件列表中隐藏多个文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个保存文件列表的文本文件.我想一起cat
他们的内容.做这个的最好方式是什么?我正在做这样的事情,但看起来太复杂了:
I have a text file that holds a list of files. I want to cat
their contents together. What is the best way to do this? I was doing something like this but it seems overly complex:
let count=0
while read -r LINE
do
[[ "$line" =~ ^#.*$ ]] && continue
if [ $count -ne 0 ] ; then
file="$LINE"
while read PLINE
do
echo $PLINE | cat - myfilejs > /tmp/out && mv /tmp/out myfile.js
done < $file
fi
let count++
done < tmp
我当时跳过了注释行并遇到了问题.必须有一个更好的方法来做到这一点,而无需两个循环.谢谢!
I was skipping commented lines and running into issues. There has to be a better way to do this, without two loops. Thanks!
推荐答案
或通过简单的命令
cat $(grep -v '^#' files) > output
这篇关于如何从Bash中的文件列表中隐藏多个文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文