I need to search for a file in Unix - what is the actual/full command w/
syntax to do so?
It doesn't have windows like explorer or anything else - just command based.
Thanks
> I need to search for a file in Unix - what is the actual/full
> command w/ syntax to do so?
find DIR -name NAME -type f -print
Replace DIR with the directory where you want to start and NAME
with the name of the file you are looking for.
Peter
--
Peter J. Acklam - pjac...@online.no - http://home.online.no/~pjacklam
Depending on where you expect the file to be, start with ls(1). The
(1), by the way, means the use of the command is documented in section
one of the manual, so you can type `man 1 locate' to get an explanation
of all the options you can use -- if you don't give a number, man(1)
will guess. If ls(1) doesn't give the expected results, you could try
locate(1), or if that fails, find(1), which is a bit harder to use and
is slower, but it has more options and can be more accurate. This list
isn't exhaustive, but lists just the most general facilities.
> It doesn't have windows like explorer or anything else - just command based.
Welcome to the world of unix[tm]. For an introduction, you could try this:
http://www.oreilly.com/catalog/lunix5/
There do exist various file-browser things for the people that can't
handle the command line, like midnight commander. It might be installed on
your system. You could ask your system administrator about it.
--
j p d (at) d s b (dot) t u d e l f t (dot) n l .
man find
What file are you searching for? What characteristics does it
have that set it apart from other files?
If you know the name, or part of it, and it is a regular file
(not a fifo or directory, etc.) then:
find /dir -type f -name '*foo*'
That will search, recursively, the entire directory tree of
/dir, for files with "foo" in their names.
find has *many* options/arguments to aid searches.
You can also have find do operations on the files it finds:
find /dir -type f -name '*foo*' -exec cat {} \
>> /home/you/newfile \;
That would append a copy of every file found, in order, to
a newfile in your home directory called "newfile". The
'{}' represents each file that is found, one at a time.
The '\' escapes (cancels) the newline so that the shell sees it
as one line. I did that only so that it would be a command that
would work as written on the commandline *and* this post would be
properly formatted. You can just put it all on one line and drop
the '\'.
You may also have the 'locate' command (it uses find and keeps
a database of your current files, which has to be updated
regularly with a utility called 'updatedb'. Usually this is
done in the background by a cron job, but you need to make
sure.
AC
See if it has "vsh" (Visual SHell) if you want simple explorer-style
functionality.
Ed.
> Thanks