打印特定目录中文件的内容 [英] print the content of files from a particular directory

查看:137
本文介绍了打印特定目录中文件的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我使用cmd显示了目录中的所有文件,

ls/home/user1/.现在,我需要显示此目录中存在的特定文件的所有内容

例如.

ls/home/user1/tmp/包含三个文件
sample1.txt sample2.txt sample3.txt sample5.js sample6.html

如何仅显示这些文件中存在的.txt文件的内容

我已经累了ls/home/user1/tmp/| grep''.txt $''|猫/home/user1/tmp

但这并不能按照我的需要工作.

请帮忙.感谢advancd

Hi,

I displayed all the files from a directory using the cmd,

ls /home/user1/. Now I need to display all content of particular files present in this directory

For ex.

ls /home/user1/tmp/ containt three files
sample1.txt sample2.txt sample3.txt sample5.js sample6.html

How to display only the content of .txt files present in these files

I have tired ls /home/user1/tmp/ | grep ''.txt$'' | cat /home/user1/tmp

But it is not working as I need.

Please help. Thanks in advancd

推荐答案

''|猫/home/user1/tmp

但这并不能按照我的需要工作.

请帮忙.在advancd中感谢
'' | cat /home/user1/tmp

But it is not working as I need.

Please help. Thanks in advancd


只需在cat中使用通配符:
Just use a wildcard with cat:
cat /home/user1/tmp/*.txt


这篇关于打印特定目录中文件的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆