Click here to Skip to main content
15,883,705 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Updated 19-Nov-12 23:29pm
v2

1 solution

Just use a wildcard with cat:
cat /home/user1/tmp/*.txt
 
Share this answer
 
Comments
srmohanr 20-Nov-12 5:35am    
Thanks for your great help.

Please tell me how to count the number of blank lines in those contents

I have tried cat /home/user1/tmp/*.txt | grep -n | wc -l
Graham Breach 20-Nov-12 5:42am    
This works for me:
cat /home/user1/tmp/*.txt | egrep '^$' | wc -l
srmohanr 20-Nov-12 5:56am    
Thanks for your great help
srmohanr 20-Nov-12 6:01am    
what should do to execute commands under the presently working directory and without using './'.
For example:

I am under ~/sample, I have a command "mycmd" in this folder. How can I execute the it by using $mycmd
srmohanr 20-Nov-12 6:03am    
'mycmd' already has an execute permission.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900