Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- clearFiles() {
- rm *.dat
- if [ $? -eq 0 ]
- then
- echo Files deleted
- fi
- }
- genFiles() {
- for (( i=1; i<=$1; i++ ))
- do
- head -c ${i}M </dev/urandom >myfile${i}mb.dat
- done
- ls -l *.dat
- }
- delFiles() {
- for f in *.dat
- do
- size=$(( $(stat -c %s $f) /1024/1024 ))
- if [ $size -gt $1 ]
- then
- rm $f
- echo Deleted file $f
- fi
- done
- ls -l *.dat
- }
- showWeather() {
- curl -s "https://weather-broker-cdn.api.bbci.co.uk/en/observation/rss/$1" | grep "<desc" | sed -r 's/<description>//g; s/<\/description>//g'
- }
- menu() {
- clear
- echo 1 - Delete all .dat files
- echo 2 - Generate .dat files
- echo 3 - Delete big .dat files
- echo 4 - List all files
- echo 5 - Planet info
- echo 6 - Show weather
- echo "x/q - Exit"
- echo -n "Choose action: "
- read -n 1 key
- echo
- }
- while true
- do
- case "$key" in
- "x" | "q" | "X" | "Q") break ;;
- "1")
- clearFiles
- read -n 1
- ;;
- "2")
- echo -n "File count: "
- read count
- genFiles $count
- read -n 1
- ;;
- "3")
- echo -n "Delete file greater than (mb): "
- read maxsize
- delFiles $maxsize
- read -n 1
- ;;
- "4")
- ls -la
- read -n 1
- ;;
- "5")
- ./script4.sh
- read -n 1
- ;;
- "6")
- echo -n "Enter city code: " # 524901 498817 5391959
- read citycode
- showWeather $citycode
- read -n 1
- ;;
- esac
- menu
- done
Advertisement
Add Comment
Please, Sign In to add comment