Repository navigation
Expand file tree
/
Copy pathwhile-loops.sh
More file actions
executable file
·79 lines (71 loc) · 1.54 KB
/
Copy pathwhile-loops.sh
File metadata and controls
executable file
·79 lines (71 loc) · 1.54 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
# INDEX=1
# while [ $INDEX -lt 6 ]
# do
# RANDOM_TAG=$RANDOM
# echo "Creating project-${INDEX}-${RANDOM_TAG}"
# mkdir ./project-${INDEX}-${RANDOM_TAG}
# ((INDEX++)) # arithmetical expansion; enclose it in double parenthesis
# done
# while [ "$CORRECT" != "y" ]
# do
# read -p "Enter your name: " NAME
# read -p "Is ${NAME} correct? " CORRECT
# done
# return code of command
# while ping -c 1 localhost >/dev/null
# do
# echo "app1 still up...."
# sleep 5
# done
#
# echo "app1 down, continuing."
# reading a file line-by-line
# LINE_NUM=1
# while read LINE
# do
# echo "${LINE_NUM}: ${LINE}"
# ((LINE_NUM++))
# done < /etc/fstab
# get the input from the output of another command
# grep ext4 /etc/fstab | while read LINE
# do
# echo "ext4: ${LINE}"
# done
# put parts of the line in different variables
# FS_NUM=1
# grep ext4 /etc/fstab | while read FS MP REST
# do
# echo "${FS_NUM}: file system: ${FS}"
# echo "${FS_NUM}: mount point: ${MP}"
# ((FS_NUM++))
# done
# simple menu system
# while true
# do
# read -p "1: Show disk usage. 2: Show uptime. " CHOICE
# case "$CHOICE" in
# 1)
# df -h
# ;;
# 2)
# uptime
# ;;
# *)
# break # break the loop
# ;;
# esac
# done
# backup mysql databases that have not been backed up recently
# -B: disables ASCII table output
# -N: disables table headers
# -e: execute command
# mysql -BNe 'show databases' | while read DB
# do
# db-backed-up-recently $DB
# if [ "$?" -eq "0" ]
# then
# continue
# fi
# backup $DB
# done