A Simple shell Script

Hi there. im creating a shell script which helps me perform simple functions when i use it, but there are still two functions which i cannot figure out yet.

1) how can I count the number of occurences of a certain file within the whole file system? (filename supplied as an argument.)

2) How can I list all the files in the current directory whose contents are identical to a filename supplied as an argument.

It may be simple but I am really stuck on this and I would be glad of some help.

Thanks very much.

Try these ideas...

  1. Count all instances of a specified file name in the file system:

    ls -a | grep -c filename

    The ls -a will list all files including the dot-files (the -a arg).
    Piping to grep -c will count (the -c arg) the hits on filename in
    the output of ls -a.

    I don't know how to execute that recursively from the
    root all the way throughout every directory in the system.

  2. List all occurances of a file name:

    ls -a | grep filename

find / -name <filename> -print | wc -l

This will search your entire file system for the file and count the number of occurances.