LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   problem with find and root (/) directory (https://www.linuxquestions.org/questions/linux-general-1/problem-with-find-and-root-directory-327735/)

lfur 05-27-2005 12:51 PM

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

username17 05-27-2005 01:04 PM

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.

druuna 05-27-2005 01:07 PM

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.

lfur 05-27-2005 01:24 PM

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

druuna 05-27-2005 01:55 PM

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).

lfur 05-27-2005 02:24 PM

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.

setenv02 05-27-2005 10:42 PM

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


All times are GMT -5. The time now is 07:09 PM.