当前位置: 动力学知识库 > 问答 > 编程问答 >

linux - viewing file's content for each file-name apearing in a list

问题描述:

I'm creating a list of file-names using the command:

ls | grep "\.txt$"

I'm getting a list of files:

F1.txt

F2.txt

F3.txt

F4.txt

I want to view the content of these files (using less / more / cat /...)

is there a way to do this by pipping?

(Btw, i got a list of file-names using a more complex command, this is just a simpler example for clarification)

网友答案:

Would this be enough?

$ cat *txt

For richer queries, you could use find and xargs:

$ find . -name "*txt" | xargs cat
网友答案:

you can try something like this:

#!/bin/bash

for i in *.txt
do
  echo Displaying file $i ...
  more  $i
done
网友答案:

What about:

cat $(ls | grep "\.txt$")
分享给朋友:
您可能感兴趣的文章:
随机阅读: