Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

updated - findit k shell script - uses menus and functions

Status
Not open for further replies.

RobJordan

MIS
Apr 3, 2001
296
US
I am posting this URL since there appears to be a limit
to the amount of text I can post in a thread and
the end of this script is being cut off.


Enjoy!

Robert Robert G. Jordan

Robert@JORDAN200.com
Unix Admin, United Airlines
 
RobertGJordan (MIS) Feb 25, 2002
Here's a sample of the script running
and the output.

# ./findit

Thank you for using findit version 1.3
Please send any questions/comments to Robert@JORDAN2000.com

Main Menu
--------------------------------------------------------------------------------
1) Find files by name
2) Find files by size
3) Find files by user
4) Find files by age
5) Find files by access date
6) Find files by file permissions
7) Custom Search (mix & match criteria)
8) Find files by text within file
9) -- Exit --
#? 1

Please enter file name to search for
* can be used as a wild card ex: *.log
enter * alone to search for all files
note: all searches are case sensative

File Name--> framework.htm
Search Path--> /prod/int01/data
Include sub-directories in this search? (y/n) [y]
Follow symbolic links? (y/n) [n] y

Executing: find /prod/int01/data/* -follow -name framework.htm -print
Searching.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................Search Complete!
1 matches found.

note: detailed results will take more time
by running an ls -ld command against each match.
Provide detailed results? (y/n) [n] y
Formatting detailed results......Done!


Basic results saved in: /tmp/TMP_LIST.21822.Results
Detailed results saved in: /tmp/TMP_LIST.21822.Detail

Display results on screen? (y/n) [y] y

Mon Feb 25 14:00:41 CST 2002
find /prod/int01/data/* -follow -name framework.htm -print

-rwxrwxr-x 1 intranet iplanet 7630 Feb 25 12:01 /prod/int01/data/htdocs/hpages/isd/procguide/html/framework.htm

Basic results saved in: /tmp/TMP_LIST.21822.Results
Detailed results saved in: /tmp/TMP_LIST.21822.Detail

Search for a text string within these files? (y/n) [n] y
Please enter text to search for
--> isd

Case-sensative search (y/n) [n]

Scanning file 1 of 1 /prod/int01/data/htdocs/hpages/isd/procguide/html/framework.htm

1 text files found
[isd] was found in 1 files
Total hits for [isd]: 23

Basic results saved in: /tmp/TMP_LIST.24363.Results
Detailed results saved in: /tmp/TMP_LIST.24363.Detail
Text search results saved in: /tmp/TMP_LIST.24363.Text_Hits

# cat /tmp/TMP_LIST.24363.Results
/prod/int01/data/htdocs/hpages/isd/procguide/html/framework.htm

# cat /tmp/TMP_LIST.24363.Detail
Mon Feb 25 14:04:02 CST 2002
find /prod/int01/data/* -follow -name framework.htm -print

-rwxrwxr-x 1 intranet iplanet 7630 Feb 25 12:01 /prod/int01/data/htdocs/hpages/isd/procguide/html/framework.htm

# cat /tmp/TMP_LIST.24363.Detail
Mon Feb 25 14:04:02 CST 2002
find /prod/int01/data/* -follow -name framework.htm -print

-rwxrwxr-x 1 intranet iplanet 7630 Feb 25 12:01 /prod/int01/data/htdocs/hpages/isd/procguide/html/framework.htm
root @ awhq7104 [/usr/local/bin]
# cat /tmp/TMP_LIST.24363.Text_Hits
Mon Feb 25 14:04:02 CST 2002
find /prod/int01/data/* -follow -name framework.htm -print
Text Search: isd
23 occurences of [isd] found in /prod/int01/data/htdocs/hpages/isd/procguide/html/framework.htm
1 text files found
[isd] was found in 1 files
Total hits for [isd]: 23
Robert G. Jordan

Robert@JORDAN200.com
Unix Admin, United Airlines
 
Trying to use your script, however running into problems. Getting the following error upon execution:
/usr3/medprogs/findit: te:: not found
/usr3/medprogs/findit: /usr/bin/date: not found

Thank you for using findit version 1.4
The latest version can always be found out dit.txt
Please send any questions/comments to Robert@JORDAN2000.com

/usr3/medprogs/findit: whoami: not found
/usr3/medprogs/findit: test: argument expected
Do I need to modify in any way ? Hope this is going to change our support area lives!!!!Supportsc
 
Yes, I probably need to work on this script to make it
more generic and add more error checking and comments.
I wrote it using the k shell on hpux.
I am not well versed on every flavor unix,
but some parts of this script are not necessary to run,
other parts can be changed to work on your system.

The date command just attempts to capture the current date.
Find out where the date command is on your system
and alter the script. The whoami command attempts
to find out our user id. Again, you can alter this
for your system.

You should be able to comment out certain parts of this
script.

I am removed some commands that are not necessary.

Also you can comment out the "Check_ID" function
by placing a # sign in front of it.

#Check_ID
Main_Menu
Search_Path
Sub_Directories
Symbolic_Links
Begin_Search
Display_Results
Text_Search
File_Maint
Exit

When you copied and pasted the script or saved it,
it's possible some of the lines go cut in two
which would produce errors.

I would get latest version from my website
I will be making some major updates over
the next few days as I get more feedback.

:)

Thank you,

Robert Robert G. Jordan

Robert@JORDAN200.com
Unix Admin, United Airlines
 
Thanks again for the input. This system flavor is just SCO UNIX. I have gotten the latest from you web site. I will "play with" this and see what happens. It appear that the commands are basically the same as far as date and whoami are valid commands here as well. Again thanks for the post, and hopefully can get editted so our support Team can utilize your script...Laura
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top