LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-21-2003, 06:47 AM   #1
pcdebb
Member
 
Registered: Aug 2003
Location: Brandon, FL
Distribution: Mageia 2
Posts: 81

Rep: Reputation: 15
finding a file


i have to find a file somewhere on the system. I've used the find file but get permission denied (find / -name filename -print) and i also used grep. My text only gives me these two ways to find files, so I don't know if maybe i'm not using the right flags or something on the find command?
 
Old 10-21-2003, 07:01 AM   #2
jkobrien
Member
 
Registered: Jun 2003
Location: Dublin, Ireland
Distribution: Slackware, LFS, Ubuntu, RedHat, Slamd64
Posts: 507

Rep: Reputation: 30
try the find command as root.
Also try the locate command.
 
Old 10-21-2003, 07:09 AM   #3
UltimaGuy
Member
 
Registered: Aug 2003
Location: Chennai, India
Distribution: PCLinuxOS .92, FC4
Posts: 840

Rep: Reputation: 31
Try the "slocate <filename>" command, and it will give you a very comprehensive list indeed. It is also very fast, as it uses a small database, where it stores the details about the files.
 
Old 10-21-2003, 07:10 AM   #4
pcdebb
Member
 
Registered: Aug 2003
Location: Brandon, FL
Distribution: Mageia 2
Posts: 81

Original Poster
Rep: Reputation: 15
actually i used find and found it mixed in all the lines of permission denied, but locate was one I found in my text also, thanx for you help tho, as I've entered these other commands in my growing notebook of notes :-)
 
Old 10-21-2003, 07:14 AM   #5
yapp
Member
 
Registered: Apr 2003
Location: Netherlands
Distribution: SuSE (before: Gentoo, Slackware)
Posts: 613

Rep: Reputation: 30
The pemission denied messages are normal. If you're running as a normal user (and you should ) you're not allowed to access all files. The reasons vary from security issues to the privacy of other users at the system.

Something that gave me some problems with the find command:
* you need to use wildcards, to indicate there can be something before or after the name.
* the -name search is case-sensitive. Use -iname for incase-sensitive searching.

For example:
Code:
find /some/folder/ -iname "*file*"
You can also use the locate command to find something quickly.
'locate' uses a database created by 'updatedb'. In the crontab (or /etc/cron.*) folders, and "updatedb" is scheduelled to run every frequently.


Grep can be used to filter text from a steam, file, or search for text in files. You can supply a regular-expression for more advanced pattern searching.

for example:
Code:
grep -E "\((WW|EE)\)" /var/log/XFree86.0.log
The (WW|EE) expression selects WW or EE from the file. the \( and \) force grep to parse the text literally.

Grep can be used to search multiple files:
Code:
grep -i -R "some pattern" ...directories
grep -i "some pattern" ...file list
And select a certain pattern from a steam: (the pipe symbol redirects the output to 'grep')
Code:
ps aux | grep kde

edit: and to supress the error mesages: (redirect stderr;2 to /dev/null)
Code:
find /some/folder/ -name ...   2>/dev/null

Last edited by yapp; 10-21-2003 at 07:16 AM.
 
Old 10-21-2003, 07:17 AM   #6
pcdebb
Member
 
Registered: Aug 2003
Location: Brandon, FL
Distribution: Mageia 2
Posts: 81

Original Poster
Rep: Reputation: 15
i knew the exact name of the file, and i'm on a student server at school executing commands. He basically told us "create a symbolic link to filename, but you have to find it on your own", so I fished around until I found the way. Plus I have one of these "quick reference" card things and all the commands were right on there.

wow, I didnt expect so many responses at this hour, guess I'm not the only geek
 
Old 10-21-2003, 07:20 AM   #7
jkobrien
Member
 
Registered: Jun 2003
Location: Dublin, Ireland
Distribution: Slackware, LFS, Ubuntu, RedHat, Slamd64
Posts: 507

Rep: Reputation: 30
Well, it is the World-Wide web ;-)
 
Old 10-21-2003, 07:23 AM   #8
pcdebb
Member
 
Registered: Aug 2003
Location: Brandon, FL
Distribution: Mageia 2
Posts: 81

Original Poster
Rep: Reputation: 15
 
Old 10-21-2003, 07:36 AM   #9
Langly
LQ Newbie
 
Registered: Jan 2003
Distribution: RH8.0; FreeBSD;
Posts: 17

Rep: Reputation: 0
hmm.. someone should mention whereis, it searches your path for the binaryfile,manpages and lib
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Finding the file size harrylmh Programming 8 04-29-2006 04:59 PM
Finding the last in a file list .. hrafn Programming 1 03-21-2005 04:45 AM
Finding File Size cmfarley19 Linux - General 1 01-24-2005 09:36 AM
Finding a device file doctorwebbox Linux - Hardware 2 10-08-2004 03:59 PM
finding most recent file wedgeworth Linux - Software 3 10-22-2003 02:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration