~johanvandegriff/unix-shell-programming-revised-edition-programs

unix-shell-programming-revised-edition-programs/find_file -rw-r--r-- 1.1 KiB
fc214385Johan Vandegriff added other old scripts, some newer ones too 1 year, 8 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/sh

root=/home/johanv/programs/other             #

$root/get_all_files $root &                  # start getting files

line=`ps | grep get_all_files`               # find the process

number=`$root/first $line`                   # find the number

echo "Search for:"                           #

read search                                  # read filename or directory name

echo -n "Searching..."                       #

wait $number >> $root/errors.txt             # wait to finish getting all files

echo "...Done"

files=`grep "$search" $root/all_files.txt`   # find files

echo "$files" > $root/results.txt

echo -n "Number of results: "                #

results=`echo "$files" | wc -l`              # calculate the number of results

echo "$results"                              # display the number of results

echo "Press enter to see them."              #

read a                                       #

if [ "$results" -gt "500" ]

then

  gedit --new-window $root/results.txt       # display the filenames

else

  cat $root/results.txt

fi

echo "Press enter to exit."                  #

read a                                       #