Complete.Org: Mailing Lists: Archives: linux-help: September 2000:
[linux-help] Re: ls
Home

[linux-help] Re: ls

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: linux-help@xxxxxxxxx
Subject: [linux-help] Re: ls
From: Tom Hull <thull@xxxxxxxxxxx>
Date: Sun, 03 Sep 2000 01:48:07 -0500
Reply-to: linux-help@xxxxxxxxx

Nathan wrote:
> 
> At 09:44 PM 9/2/00 -0500, you wrote:
> >ls -R * will recursively list and descend through all directories from
> >the current working directory.  It won't tell you whether the file is
> >there or not. It's better to use this instead :
> >
> >find . -name filename 2> /dev/null
> >
> >where the file name is the file you're looking for and the dot is the
> >cwd.
> 
> The dot is the cwd?  What is cwd?

Current Working Directory. If you type in a pathname that does not begin
with / that pathname is treated as relative to your current working directory.

In the find command above, you could also use $PWD, since the shell keeps
the absolute pathname of the current working directory in variable PWD.

> What could I add to this command to make it give me one screen at a time,
> allowing me to hit a key when I'm ready to look at the next screen?
> 
> DOS:  dir *.o /s /p

Pipe it into more or less; for example:

  find . -name filename 2>/dev/null | less

Once you have a screen full, use space to get the next screenful. q-return
will quit. You can use the cursor arrows to scroll up/down a line, page up/
page down, various other commands. The main difference between less and more
is that less lets you scroll backwards; more doesn't. The reason more is
called more is that it waits for you to tell it to give you more. The reason
less is called less beats me; it was written later, so the name is some sort
of spin-off, but doesn't make sense.

The reason for the "2>/dev/null" is to throw away complaints that find may
make about directories that it/you don't have access to. You can generally
leave that out if you're searching your own directories.

> If I get tired of looking at the many screens of files, how can I make it 
> stop?
> 
> DOS:  Ctrl-C

To find out, type: stty -all; then look for where it says something like:

  intr=^C

This tells you that the interrupt character is ^C (control-C). You can
change this by typing: stty intr=^?; or whatever character you want (^?
is the key marked "Delete"). So, unlike DOS, it is programmable, but ^C
is the most common choice.

> >If you wish, -ctime and others will allow you to find files with
> >creation times and other forms of search exist. The 2> /dev/null tells
> >all the error messages to go to /dev/null which is a special file which
> >basically just directs trash off into thin air.
> >
> >Nathan wrote:
> >
> > > I've got a simple question:
> > >
> > > Is there a way, using the "ls" command, to search a directory and all
> > > sub-directories for a file?

ls -R will search all sub-directories, but then you have to search its
output to find the file, which is complicated because the directory path
is on one line, the filename on another. The find command above works
better.

-- 
/*
 *  Tom Hull * thull@xxxxxxxxxxx * http://www.ocston.org/~thull/
 */

-- This is the linux-help@xxxxxxxxx list.  To unsubscribe,
visit http://tmp2.complete.org/cgi-bin/listargate-aclug.cgi


[Prev in Thread] Current Thread [Next in Thread]