Jump to content

linux ls command

Go to solution Solved by myselfolli,

What you're looking for is a pipe (this thing -> | ) which is used to 'pipe' the output of one command into another command.

 

In your case you could use

ls | grep d*

which would pipe the output of ls into the grep command, which outputs only stuff starting with a d

I know that ls lists out all the content of a directory while ls lists out all teh content of a directory with detail. So how do I go about listing out all the content without detail that starts with a particular letter? 

 

Say I want to list out content starting with d. from google searching, ls /etc/* dosen't work, ls d* dosen't work and ls -d /etc/[d]* dosen't work 

 

Link to comment
Share on other sites

Link to post
Share on other sites

What you're looking for is a pipe (this thing -> | ) which is used to 'pipe' the output of one command into another command.

 

In your case you could use

ls | grep d*

which would pipe the output of ls into the grep command, which outputs only stuff starting with a d

75% of what I say is sarcastic

 

So is the rest probably

Link to comment
Share on other sites

Link to post
Share on other sites

18 minutes ago, myselfolli said:

snip

Thank you for your help. Turns out that 

ls D*

also works despite not working eariler today. 

Link to comment
Share on other sites

Link to post
Share on other sites

6 minutes ago, bindydad123 said:

Thank you for your help. Turns out that 


ls D*

also works despite not working eariler today. 

"ls d*" and "ls D*" are two different commands.

Link to comment
Share on other sites

Link to post
Share on other sites

28 minutes ago, KarathKasun said:

"ls d*" and "ls D*" are two different commands.

That is to say, it is case sensitive.  ls d* searches for files that begin with a lowercase d, ls D* for files with an uppercase D.

 

ls | grep -i d*  will ignore case.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×