forked from r3klaw/readfile-shellscript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
my_new_whois.sh
49 lines (40 loc) · 1.33 KB
/
my_new_whois.sh
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
#!/bin/sh
filename="$1"
if [[ $filename ]]
then
echo "user: "$USER
var=$(date +"%FORMAT_STRING")
now=$(date +"%m_%d_%Y_%H_%M_%S")
echo "date:" $now
timestamp=$(date +"%Y_%m_%d_%H_%M_%S")
choices=(
'netname'
'inetnum'
'people'
'quit'
)
PS3="Please choose an option between 1-4: "
select choice in "${choices[@]}" ; do
[[ -n $choice ]] ||
echo "invalid input"
case $choice in
netname)
sort ${filename} | grep "netname" > ${choice}_${timestamp}.txt
echo "Scripted completed and exported as" ${choice}_${timestamp}.txt
echo "file created at:" ${timestamp} >> ${choice}_${timestamp}.txt;;
inetnum)
sort -V ${filename} | grep "inetnum" > ${choice}_${timestamp}.txt
echo "Scripted completed and exported as" ${choice}_${timestamp}.txt
echo "file created at:" ${timestamp} >> ${choice}_${timestamp}.txt;;
people)
grep "person" ${filename} | sort | uniq > ${choice}_${timestamp}.txt
echo "Scripted completed and exported as" ${choice}_${timestamp}.txt
echo "file created at:" ${timestamp} >> ${choice}_${timestamp}.txt;;
quit)
echo "program ended";
break;;
esac
done
else
echo "please Execute the script in this order: myscript.sh [inputFile] "
fi