The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Grep help flood Shell Programming and Scripting 3 06-05-2008 10:14 PM
Grep Aejaz UNIX for Advanced & Expert Users 3 04-30-2008 04:10 AM
grep dineshr85 Shell Programming and Scripting 1 10-10-2007 01:52 AM
how to exclude the GREP command from GREP yamsin789 UNIX for Advanced & Expert Users 2 10-04-2007 11:59 PM
Make grep -c display like grep -n? Jerrad Shell Programming and Scripting 2 08-24-2006 09:20 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 11-26-2007
Registered User
 

Join Date: Mar 2007
Posts: 25
Unhappy ls -a | grep .*

Hi Frineds,

I am executing this command ls -a | grep .* on my systems but it is showing confusing output so can anyone please tell me what output it is showing.


Regards--
krishna_sicsr
Reply With Quote
Forum Sponsor
  #2  
Old 11-26-2007
Moderator
 

Join Date: Dec 2003
Location: /dev/fl
Posts: 1,061
Assuming you want to ouput a list of all files starting with '.' (dot) e.g. .profile, .cshrc, etc.
the easiest way is

Code:
ls -a .*
Reply With Quote
  #3  
Old 11-26-2007
Registered User
 

Join Date: Mar 2007
Posts: 25
Unhappy

NO I am using

ls -a | grep .* only but what output it is showing I am not getting on different systems it is showing different output.

ls -a .* shows output in the form of directory within directory form.

So please if are getting that what output ls -a | grep .* is showing let me know.
Reply With Quote
  #4  
Old 11-26-2007
Registered User
 

Join Date: Dec 2005
Posts: 74
murphy's method is the better one
Please show the output, sometime, the ouput speaks better that our words

RUV
Reply With Quote
  #5  
Old 11-26-2007
Registered User
 

Join Date: Feb 2007
Location: Pune, Dehradun (INDIA), Michigan(US)
Posts: 187
Quote:
Originally Posted by krishna_sicsr View Post
NO I am using

ls -a | grep .* only but what output it is showing I am not getting on different systems it is showing different output.

ls -a .* shows output in the form of directory within directory form.

So please if are getting that what output ls -a | grep .* is showing let me know.
Hey,

When we use murphy's syntax we'll get something like that :

------------------------------------------------------------------
.mh_profile .profile .sh_history .vi_history

.:
. VIPSCFqstat_output_archive smit.log
.. VIPSqstat_output smit.script
.mh_profile VIPSqstat_output_archive smit.transaction
.profile XptionAudit_SuccessMessages.txt sumanta
.sh_history XptionsAuditFailMessages.txt temp.598178
.ssh XptionsAuditMessages.txt tempdspmq.txt.598178
.vi_history backup test1
EBRM deploy test2
GetRateVIPSCF.gz gtb vinay
HLD_LLD.zip mike vips
ILLogs mqILScript.sh vipscf
Mail sanjay vipsscript
VIPSCFqstat_output sed wbimb6_broker

..:
. .. dspmq_temp mqsi mqsiadm mqsiprd mqsitst t1917mk t5615rw

.ssh:
. .. known_hosts

------------------------------------------------------------------

where all the hidden files are listed including the normal files and directories.

If want to list out only directories the use the conditional script for that

if [ -f ] then

fi

OR

id [ -d ] then

fi


where as ls -a | grep .* command will list all the files that are hidden and nonhidden files, and in those you will serach the string ".*"
So obviously in different files and systems output will be different.

Thanks
Reply With Quote
  #6  
Old 11-26-2007
Read Only
 

Join Date: Nov 2007
Posts: 165
How about using "ls -a | grep \.*"?
Reply With Quote
  #7  
Old 11-26-2007
kahuna's Avatar
Registered User
 

Join Date: Apr 2007
Posts: 148
use
Code:
ls -a | grep '.*'
What is happening is that you are getting shell filename expansion. Without the single quotes, shell is expanding to something like

Code:
ls -a | grep .profile .sh_history .etc
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 07:22 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0