LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-27-2005, 12:51 PM   #1
lfur
Member
 
Registered: Jul 2003
Location: Slovenia
Distribution: Slackware & FreeBSD
Posts: 209

Rep: Reputation: 30
problem with find and root (/) directory


Hello!

As writen in subject, I have some problems using find with / directory. I want to list all the files on the system using: find /
It works fine on the command line. But when added in a script it displays nothing. So, if I write

Code:
for i in `find /`; do
echo $i
done
I get nothing. But when using some other directory it works fine, printing all the files in it. Does anybody have any idea. I asked a couple of people but nobody knows. Also tried it on several machines but the effect stays the same.

Thank you and enjoy,
Luka
 
Old 05-27-2005, 01:04 PM   #2
username17
Member
 
Registered: Aug 2004
Location: Norfolk VA
Distribution: Slackware 11
Posts: 230

Rep: Reputation: 30
Hello,
Locate (or slocate, if on slackware) should do the trick.

If you've never used locate before, you need to create the dB.

As root:
Code:
updatedb
This should create the dB

then:
Code:
locate *
That should list all files on the HD, if you issue the command from /.
-Jason

P.S. If you've already created the dB, locate -u, will update it.
 
Old 05-27-2005, 01:07 PM   #3
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

What does your script look like? 'Cause it works for me:
Code:
#!/bin/bash
for i in `find /`; do
echo $i
done
You do realize that find / -print will give you the same result? (You could go without the -print part).

Hope this helps.
 
Old 05-27-2005, 01:24 PM   #4
lfur
Member
 
Registered: Jul 2003
Location: Slovenia
Distribution: Slackware & FreeBSD
Posts: 209

Original Poster
Rep: Reputation: 30
Hi!

username17:

sure locate would fix the problem but not all machines the script will run on will have slocate database (not that they will not have it, but it should be done so they don't have to have it).
About the script: it's something like TripWire, it lists one file at the time, calculates it's md5 and sha1 digest, inode, owner, group, size ....

druuna:

Tried that before but it doesnt work.

Thank you both, but search for the soulution continues

Enjoy, Luka
 
Old 05-27-2005, 01:55 PM   #5
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi again,

Show what you have scripted so far, gives us an idea of what could have gone wrong (if it's anything in the script that is).
 
Old 05-27-2005, 02:24 PM   #6
lfur
Member
 
Registered: Jul 2003
Location: Slovenia
Distribution: Slackware & FreeBSD
Posts: 209

Original Poster
Rep: Reputation: 30
Hi!

There actually is nothing else than what i have posted before. Well the problem appears even if I write the part of the script shown above on the command line.

so:

for i in `find /`; do echo $i; done

does nothing for me.

Enjoy,
Luka

P.S. But the thing is: i've tried it on several machines running from *BSD to Slack. And nothing changes.
 
Old 05-27-2005, 10:42 PM   #7
setenv02
Member
 
Registered: Apr 2005
Location: Chicago,IL
Distribution: redhat 9
Posts: 32

Rep: Reputation: 15
Type in the command line locate / for the root directory if you want to list all the files
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I find what directory is on what partition? mijohnst Linux - Newbie 2 10-05-2005 04:16 PM
apache root directory problem tbrenner Linux - Networking 1 09-12-2005 12:54 PM
How to find root directory of external PCMCIA? nr4g3d Linux - Newbie 1 03-13-2004 01:41 PM
Can't find root directory for Apache 2.0 (Mandrake 9.2) kaega2 Linux - Software 6 02-13-2004 06:08 PM
Can't find CD images directory rrose42 Linux - Software 3 02-04-2002 06:01 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:39 PM.

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
Open Source Consulting | Domain Registration