
安裝方式非常簡單: sudo apt-get install guake sudo apt-get update 安裝後如果希望在登入後就啟動常駐,在LXDE桌面系統下可以執行:
sudo ln -s /usr/share/applications/guake.desktop /etc/xdg/autostart/
更改設定可以在視窗西岸的情況下按下滑鼠右鍵,選擇 Preferences :
可以修改一些設定或是自訂快捷鍵:


3. 確認一下路徑是否正確,然後按下「OK」。這樣在 Host OS 中 VirtualBox 這邊的設定就完成了,接下來是 Guest OS (Ubuntu)中的設定。
4. 在Ubuntu中(在 Guest OS 中)修改 /etc/group,將所有需要用到分享資料夾的帳號加入 vboxsf 群組。首先找尋「vboxsf」這個群組,正常來說應該會像這樣:vboxsf : x : 999 :
然後加上我的帳號名字jkchang,如果要加入多個帳號,就用逗號分隔。




$ cat ex9-k1
klim 10 20 milk 199 joe 20
# klim is appeared again!
oak 100 red 200 10 klim 30
joe 199 marry 20 julie 2000 #joe joe
$ ./ex9.awk < ex9-k1
klim = 20.00
milk = 199.00
oak = 100.00
red = 105.00
joe = 109.50
marry = 20.00
julie = 2000.00
$
解答:
#!/usr/bin/awk -f
BEGIN {
}
{
sub(/#.*/,"")
if ( $0 != "" ) {
for (i=1; i<=NF; i++) {
if ( $i ~ /[a-z]/ ) { # $1 is name
name=$i
}
else { # $1 is number
array[name]=array[name]+$i
num_count[name]=num_count[name]+1
}
} #for i END
} #if END
}
END {
for (i in array)
printf("%s = %.2f\n",i, array[i]/num_count[i])
}
執行結果:
$ cat k1 10 20 30 #this is a comment 8 7 # this is also a comment 2 $ ./ex8.awk k1 the max three are: 30 20 10 the average is : 12.83 $
解答:
#!/usr/bin/awk -f
BEGIN {
}
{
sub(/#.*/ , "")
if ( $0 != "" ) {
for (i=1; i<=NF; i++) {
num[count]=$i
sum+=$i
count++
} #for END
} #if END
}
END {
asort(num) #sort num[] array
printf("the max three are: %d %d %d\n",num[count],num[count-1],num[count-2])
printf("the average is : %.2f\n",sum/count)
}
注意:程式中asort函數在GNU awk 3.1才有提供
執行結果:
$ cat ex7-k1
klim 10 20 30 milk 199
oak 100 red 200 10
joe 199 20 marry 20 julie 2000
$ ./ex7.sh < ex7-k1
klim = 20.00
milk = 199.00
oak = 100.00
red = 105.00
joe = 109.50
marry = 20.00
julie = 2000.00
$
解答:
#!/bin/bash
function AVERAGE () {
avg=$(echo "scale=2; $2/$3" | bc)
echo "$1 = $avg"
}
function DATA () {
#if [[ $1 != [0-9]* && -n $1 ]]; then
if [[ $1 =~ [a-z]+ && -n $1 ]]; then
#echo "name:$1"
name[index]=$1
let index+=3
sum=0
count=0
else
let sum=sum+$1
if [ ! -z $1 ]; then
let count++
fi
name[index-2]=$sum
name[index-1]=$count
fi
}
index=1
while read line
do
if [ "$line" != "" ]; then
set $(echo $line)
field=$# #*** $# is field count
for ((i=1; i<=field; i++))
do
#echo "data:$1"
DATA $1
shift
done
fi
done #while END
for ((i=1; i<=index-3; i=i+3))
do
#echo "Name:${name[$i]} sum=${name[i+1]} count=${name[i+2]}"
AVERAGE ${name[$i]} ${name[i+1]} ${name[i+2]}
done
執行結果:
解答:
#!/bin/bash
#calc average function
function AVERAGE () {
avg=$(echo "scale=2; $1/$2" | bc )
#echo "the average is : $avg"
}
#bubble sort function
function SORT() {
for ((i=0; i<count; i++))
do
for ((j=i; j<count; j++))
do
if [ ${data[j]} -gt ${data[i]} ]; then
let temp=data[j]
let data[j]=data[i]
let data[i]=temp
fi
done
done
}
if [ -z $1 ]; then #manual input
while read line
do
if [ "$line" != "" ]; then
#set $(echo $line | tr : ' ')
set $(echo $line)
field=$#
for ((i=1; i<=field; i++))
do
data[count]=$1
let sum+=$1
let count+=1
shift
done
else
break
fi
done<&0
else #file(s) input
total_file=$#
for ((i=1; i<=$total_file; i++)) #file name put in f[] array
do
f[i]=$1
shift
done
for ((j=1; j<=$total_file; j++))
do
exec<"${f[j]}"
while read line
do
set $(echo $line)
field=$#
for ((i=1; i<=field; i++))
do
data[count]=$1
let sum+=$1
let count+=1
shift
done
done
done #for END
fi
SORT #Run Bubble sort function
echo "the max three are: ${data[0]} ${data[1]} ${data[2]}"
AVERAGE $sum $count #Run calc average function
echo "the average is : $avg"
執行結果: