duplicate directories

Hi,

I have file which users like

filename ->"readfile", following entries

peter
john
alaska
abcd
xyz

and i have directory /var/

i want to do first cat of "readfile" line by line and first read peter in variable and also cross check with /var/ how many directories are avaialble with this name "peter", that can many.

In some word if i have userids file and how can i trace those particular userids duplication in a directory, might be one user has copied another directory and might be one person have copied 5 persons directories.

Kindly advice.

Regards,
Bash

this will help you read the file one line at a time:

for line in `cat newfile`
do
    echo $line
done

instead of echoing, do whatever you want with $line

Beware of the Herder of Useless Cats! :smiley:

while read line
do
  echo "$line"
done < file

Regards

dear all,

Thanks for reply but problem is that how i can trace that users file from /var/usershome/, because peter user folder is available in other folders too, for example.

/var/usershome/abcd/xyz/peter
/var/usershome/sunn/peter
/var/usershome/john/imp/peter
/var/usershome/kanni/proj/peter

in this way other users are also available in other other users directories, so i want that list which will compare my users files that read first user from file and search
/var/usershome/ directory and whereever that find for example user "peter" display full path.

Regards,
Bash

Try the find command:

find /var/usershome/ -type d -name peter | while read line
do
  echo "$line"
done

Regards

you can use this in ksh

find /usr -name peter -print 2>/dev/null

this will give u the correct full path

Thanks, but all above command will show for only one user peter, as i said, users file is separate, i want to make each user in that directory wherever user occurance exist.

Regards,
Bash

For example.

/var/usershome/abcd/xyz/peter
/var/usershome/sunn/kasi
/var/usershome/john/imp/mogan
/var/usershome/kanni/proj/peter
/var/usershome/abcd/xyz/john
/var/usershome/sunn/abcd
/var/usershome/john/imp/kanni
/var/usershome/kanni/proj/abcd

above file show users names.
1.peter
2.kasi
3.mogan
4.peter
5.john
6.abcd
7.kanni

might be above said users directories are available in each other users directory, due to that hard-disk is filling up.

Regards,
Bash.

This should gives a list of the directories of the users:

while read user
do
  echo "List of user $user :"
  find /var/usershome/ -type d -name "$user"
done < readfile

Regards