Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Linux
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 20-Nov-12 0:15am
srmohanr1.1K
Edited 20-Nov-12 0:29am
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Just use a wildcard with cat:
cat /home/user1/tmp/*.txt
  Permalink  
Comments
srmohanr at 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 at 20-Nov-12 5:42am
   
This works for me:
cat /home/user1/tmp/*.txt | egrep '^$' | wc -l
srmohanr at 20-Nov-12 5:56am
   
Thanks for your great help
srmohanr at 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 at 20-Nov-12 6:03am
   
'mycmd' already has an execute permission.
Graham Breach at 20-Nov-12 6:06am
   
If you really want to do that, you will have to add "./" to your path. Exactly how you do that depends on which shell you are using.
 
Having to use "./" means that you do not accidentally run files in the current directory, which is a good thing.
srmohanr at 20-Nov-12 6:10am
   
It have tried export PATH=~/sample:$PATH
 
It's working.
 
Thanks for your valuable information.
srmohanr at 20-Nov-12 6:39am
   
I have a file contains group of words from a to z. Now I need to get all the words that have a,e,i,o,u in order
 
For example : abstancious.
 
I have tried cat /home/user1/tmp/file.txt | grep [aeiou]
 
But it showing all files that starts with those words.
 
Please help me

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



Advertise | Privacy | Mobile
Web03 | 2.8.1411022.1 | Last Updated 20 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100