Shell Script

jrustad24

New Member
Credits
43
I need to create a variable script that uses the "find" utility to search the home directory for files. Example; (./findFile.sh data) The search also needs to be case-insensitive. The results should look like what is in the attachment.
 

Attachments



dos2unix

Well-Known Member
Credits
2,962
This looks like a homework assignment.

"find" will .. ummm... find files.

find / -name findFile.sh

The "/" is where the search starts from, so if you know the file is somewhere under /home, you could do something like...

find /home -name findFile.sh

the -name flag tells it to match the name exactly.
If you use -iname instead, it becomes case insensitive.

There are other flags such as how many directories deep you want to search,
Do you want to list symbolic links or not?

There are flags for newer files, so that if it finds the same file name more than once
it will show you which is the newest.
You can find files, symbolic links, directories, even sockets.

Most of this can be found out by reading the man pages.

man find

.
 

captain-sensible

Well-Known Member
Credits
7,612
name of file will be findFile.sh

well i guess the common element is /home/user/

so start from home
#!/bin/sh
cd ~
echo $(pwd)
ls -l | find -type f


//along those lines geany is quite good for playing with code and running !
 


Members online


Top