Computing.Net > Forums > Unix > using find comman

using find comman

Reply to Message Icon

Original Message
Name: hoichoi
Date: May 12, 2003 at 19:56:36 Pacific
Subject: using find comman
OS: Unix
CPU/Ram: 256
Comment:

Hi..
in a directory if i use just find command in such a way like ..
find -fprint tmp.txt
it will wrint in the file in such a way
.
./test
./b
./test1
./ass1
./gp
./pola
./pola/ttt

so from there how i can get just the file name out of it like suppose the last line is ./pola/ttt here ttt is the file name so how i can get just the file name ttt or inlcuding the path like "/pola/ttt"

Regards
HoiChoi


Report Offensive Message For Removal

Response Number 1
Name: FishMonger
Date: May 15, 2003 at 16:46:52 Pacific
Subject: using find comman
Reply: (edit)

You'll need to write a script to parse the file using basename to get the name of the file and dirname to get the path. Depending on what your goal is, you might find it easier to use ls instead of find; like this:

ls -R . > tmp.txt

Your file would have this format:

/:
bin
etc
home
lib
tmp
tmp.txt
usr
var

/bin:
awk.exe
basename.exe
bash.exe
bashbug
bunzip2.exe
bzcat.exe

Then you can use a script to parse the file into arrays or hashes where the path is the name of the array or key to the hash and the file names are the values. I can write a Perl script that does it or you can do it in a shell script.

If you want the Perl script, email me. This is a poor forum for posting code since it doesn't (easily) allow the posting of certain code fragments.


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: using find comman

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software