Skip to content

Commit 1adfe4b

Browse files
committed
add bash script argument basic
1 parent f99a25c commit 1adfe4b

26 files changed

+1700
-1688
lines changed

README.md

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
1-
My Bash Scripts Collection and Configs Note
2-
===========================================
3-
4-
5-
## Desc
6-
> my daily used bash scripts collections and script note
7-
8-
## Example MD
9-
10-
Text attributes _italic_,
11-
**bold**, `monospace`.
12-
13-
Horizontal rule:
14-
15-
---
16-
17-
Bullet list:
18-
19-
* apples
20-
* oranges
21-
* pears
22-
23-
Numbered list:
24-
25-
1. lather
26-
2. rinse
27-
3. repeat
28-
29-
An [example](http://example.com).
30-
31-
![Image](Icon-pictures.png "icon")
32-
33-
> Markdown uses email-style > characters for blockquoting.
34-
35-
1+
My Bash Scripts Collection and Configs Note
2+
===========================================
3+
4+
5+
## Desc
6+
> my daily used bash scripts collections and script note
7+
8+
## Example MD
9+
10+
Text attributes _italic_,
11+
**bold**, `monospace`.
12+
13+
Horizontal rule:
14+
15+
---
16+
17+
Bullet list:
18+
19+
* apples
20+
* oranges
21+
* pears
22+
23+
Numbered list:
24+
25+
1. lather
26+
2. rinse
27+
3. repeat
28+
29+
An [example](http://example.com).
30+
31+
![Image](Icon-pictures.png "icon")
32+
33+
> Markdown uses email-style > characters for blockquoting.
34+
35+

apache-restart.sh

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
#!/bin/bash
2-
/usr/bin/systemctl restart httpd
3-
#/usr/bin/systemctl start httpd
4-
5-
for (( ; ; ))
6-
do
7-
echo "checking"
8-
sleep 120
9-
if [ `ps auxwwww|grep httpd|grep -v grep|wc -l` -gt 0 ]
10-
then
11-
echo Apache is running.
12-
break
13-
else
14-
echo Apache is not running.
15-
/usr/bin/systemctl start httpd
16-
fi
17-
18-
done
19-
20-
# put this file in /etc/cron.daily (centos 7)
1+
#!/bin/bash
2+
/usr/bin/systemctl restart httpd
3+
#/usr/bin/systemctl start httpd
4+
5+
for (( ; ; ))
6+
do
7+
echo "checking"
8+
sleep 120
9+
if [ `ps auxwwww|grep httpd|grep -v grep|wc -l` -gt 0 ]
10+
then
11+
echo Apache is running.
12+
break
13+
else
14+
echo Apache is not running.
15+
/usr/bin/systemctl start httpd
16+
fi
17+
18+
done
19+
20+
# put this file in /etc/cron.daily (centos 7)

bash-argument.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
# example of passing argument to bash script
3+
4+
#basic arg get using dolarsign $ and number of arg
5+
echo "#argument splite using space up to 3 word/argument. => " $1 $2 $3
6+
7+
#get all argument and store in array
8+
args=("$@")
9+
echo "#argument in array =>" ${args[0]} ${args[1]} ${args[2]}
10+
11+
#get number of arg passed
12+
echo "Number of argument => " $#

bash-code.sh

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
#!/bin/bash
2-
e='echo -en' # shortened echo command variable
3-
ESC=$( $e "\033") # variable containing escaped value
4-
CLEAR(){ $e "\033c";} # clear screen
5-
CIVIS(){ $e "\033[?25l";} # hide cursor
6-
CNORM(){ $e "\033[?12l\033[?25h";} # show cursor
7-
TPUT(){ $e "\033[${1};${2}H";} # terminal put (x and y position)
8-
COLPUT(){ $e "\033[${1}G";} # put text in the same line as the specified column
9-
MARK(){ $e "\033[7m";} # select current line text
10-
UNMARK(){ $e "\033[27m";} # normalize current line text
11-
DRAW(){ $e "\033%@";echo -en "\033(0";} # switch to 'garbage' mode to be able to draw
12-
WRITE(){ $e "\033(B";} # return to normal (reset)
13-
BLUE(){ $e "\033c\033[0;1m\033[37;44m\033[J";} # clear screen, set backgrou
1+
#!/bin/bash
2+
e='echo -en' # shortened echo command variable
3+
ESC=$( $e "\033") # variable containing escaped value
4+
CLEAR(){ $e "\033c";} # clear screen
5+
CIVIS(){ $e "\033[?25l";} # hide cursor
6+
CNORM(){ $e "\033[?12l\033[?25h";} # show cursor
7+
TPUT(){ $e "\033[${1};${2}H";} # terminal put (x and y position)
8+
COLPUT(){ $e "\033[${1}G";} # put text in the same line as the specified column
9+
MARK(){ $e "\033[7m";} # select current line text
10+
UNMARK(){ $e "\033[27m";} # normalize current line text
11+
DRAW(){ $e "\033%@";echo -en "\033(0";} # switch to 'garbage' mode to be able to draw
12+
WRITE(){ $e "\033(B";} # return to normal (reset)
13+
BLUE(){ $e "\033c\033[0;1m\033[37;44m\033[J";} # clear screen, set backgrou

bash-diskusage

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
date
2-
echo "%0ADisk Space";
3-
df -h | grep 'home' | awk '{ print "%0AHDD: " $2 " FREE: " $3 }'
4-
echo "%0A%0A-MysqlCentral 01 "
5-
cd /home/mysqlcentral_baru/data/
6-
du -sh * | tail -n 2 | head -n 1 | awk '{ print "%0ADate: " $2 " Size: " $1 }'
7-
du -sh * | tail -n 1 | awk '{ print "%0ADate: " $2 " Size: " $1 }'
8-
9-
echo "%0A%0A-Osscentral 3 PHP 7 (new)"
10-
cd /home/osscentral3/html/
11-
du -sh * | tail -n 2 | head -n 1 | awk '{ print "%0ADate: " $2 " Size: " $1 }'
12-
du -sh * | tail -n 1 | awk '{ print "%0ADate: " $2 " Size: " $1 }'
1+
date
2+
echo "%0ADisk Space";
3+
df -h | grep 'home' | awk '{ print "%0AHDD: " $2 " FREE: " $3 }'
4+
echo "%0A%0A-MysqlCentral 01 "
5+
cd /home/mysqlcentral_baru/data/
6+
du -sh * | tail -n 2 | head -n 1 | awk '{ print "%0ADate: " $2 " Size: " $1 }'
7+
du -sh * | tail -n 1 | awk '{ print "%0ADate: " $2 " Size: " $1 }'
8+
9+
echo "%0A%0A-Osscentral 3 PHP 7 (new)"
10+
cd /home/osscentral3/html/
11+
du -sh * | tail -n 2 | head -n 1 | awk '{ print "%0ADate: " $2 " Size: " $1 }'
12+
du -sh * | tail -n 1 | awk '{ print "%0ADate: " $2 " Size: " $1 }'

0 commit comments

Comments
 (0)