unix: how to concatenate files matched in grep
问题 I want to concatenate the files whose name does not include "_BASE_". I thought it would be somewhere along the lines of ... ls | grep -v _BASE_ | cat > all.txt the cat part is what I am not getting right. Can anybody give me some idea about this? 回答1: Try this ls | grep -v _BASE_ | xargs cat > all.txt 回答2: You can ignore some files with ls using --ignore option and then cat them into a file. ls --ignore="*_BASE_*" | xargs cat > all.txt Also you can do that without xargs : cat $( ls --ignore=