For a long time I've been using various formats of apt-cache search and stuff, and its such a crushing bore having to type in commands one after another, so I've written a script to do it all for me, whilst I've been listening to "Dad's Army"! :)

 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
50
51
52
53
54
55
56
57
#!/bin/bash
#: Title                : want
#: Date                 : November 2013
#: Author               : Sharon Kimble
#: Version              : 1.0
#: Times edited         : 11
#: Description          : to easily show a list of programmes, choose one and install it, and then update the 'universal database'
#: Options              : 1, all listed in variables
#: License              : GNU GPL 3.0 or later
####################################################
# Changelog.
# * 17-11-13 - initial version of the script,
# logs output, added ability to install, and update
# the universal database.
####################################################
# Variables
logfile="/home/boudiccas/logs/want.txt"
####################################################
exec > >(tee -a $logfile) 2>&1

# Searches the apt-cache
echo "What programmes would you like to see? One word answer please!"
echo
read programme
echo
apt-cache search "$programme"
echo

# Uses apt-cache policy to show info regarding one programme
echo "What programme do you want to see more information of?"
echo
read programme
echo
apt-cache show "$programme" | grep -i description -A 8

apt-cache policy "$programme"   #shows whether installed or not, and repo of it.

# Install it?
echo 
{   
    read -p "Do you want to install this programme? " yn
    case $yn in
        [Yy]* ) sudo apt-get install "$programme";; 
        [Nn]* ) exit;;
        * ) echo "Please answer yes or no. ";;
    esac
}

# use updatedb
echo
    read -p "Do you want to update the universal database? " yn
   case $yn in
        [Yy]* ) sudo updatedb;;
        [Nn]* ) exit;;
        * ) echo "Please answer yes or no. ";;
    esac
exit

And this is what the script looks like in action -

Figure 1



Comments

comments powered by Disqus