pavement

Ls

From FreeBSDwiki
(Difference between revisions)
Jump to: navigation, search
Line 6: Line 6:
  
 
[[ls]] can (and is) used in conjunction with [[grep]] by using a [[pipe]] to send [[ls]] output -- which can easily fill your screen with enough entries to make you cross-eyed -- to more easily find what you're looking for. To give an example, let's say you're looking for a file that begins with '''name''' in your /etc directory. Doing an '''ls /etc''' gives you far too many entries and '''la -l''' the same thing but scrolling past you even faster. You could do a
 
[[ls]] can (and is) used in conjunction with [[grep]] by using a [[pipe]] to send [[ls]] output -- which can easily fill your screen with enough entries to make you cross-eyed -- to more easily find what you're looking for. To give an example, let's say you're looking for a file that begins with '''name''' in your /etc directory. Doing an '''ls /etc''' gives you far too many entries and '''la -l''' the same thing but scrolling past you even faster. You could do a
  dave@samizdata# '''ls | more'''
+
  dave@samizdata% '''ls | more'''
 
and look for all files that begin with '''name'''. But why waste your time going over each entry?
 
and look for all files that begin with '''name'''. But why waste your time going over each entry?
  dave@samizdata# '''ls -la | grep name'''
+
  dave@samizdata% '''ls -la | grep name'''
 
will give you a long list of all files that have '''name''' in them.
 
will give you a long list of all files that have '''name''' in them.
 
   
 
   
  
 
[[Category:System Commands]]
 
[[Category:System Commands]]

Revision as of 02:32, 28 August 2004

Equivalent to Windows' dir. Somebody should write a short article demonstrating its use and the more commonly used flags, and also a very brief treatise on how to use it with grep to good effect.

Most common flags:

-a -- lists all files, including hidden files
-l -- gives long listing, including permissions, owner, group and size

ls can (and is) used in conjunction with grep by using a pipe to send ls output -- which can easily fill your screen with enough entries to make you cross-eyed -- to more easily find what you're looking for. To give an example, let's say you're looking for a file that begins with name in your /etc directory. Doing an ls /etc gives you far too many entries and la -l the same thing but scrolling past you even faster. You could do a

dave@samizdata% ls | more

and look for all files that begin with name. But why waste your time going over each entry?

dave@samizdata% ls -la | grep name

will give you a long list of all files that have name in them.

Personal tools