mirror of
https://github.com/dunwu/linux-tutorial.git
synced 2024-04-15 19:55:24 +08:00
format codes
This commit is contained in:
parent
d336b79af1
commit
0c58f678fe
@ -1,7 +1,7 @@
|
||||
# EditorConfig helps developers define and maintain consistent
|
||||
# coding styles between different editors and IDEs
|
||||
# http://editorconfig.org
|
||||
# 所有文件换行使用 Unix like 风格(LF),bat 文件使用 win 风格(CRLF)
|
||||
# 所有文件换行以 Unix like 风格(LF),win 格式特定的除外(bat)
|
||||
# 缩进 java 4 个空格,其他所有文件 2 个空格
|
||||
|
||||
root = true
|
||||
@ -11,9 +11,8 @@ root = true
|
||||
end_of_line = lf
|
||||
|
||||
# Change these settings to your own preference
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
max_line_length = 120
|
||||
indent_size = 2
|
||||
|
||||
# We recommend you to keep these unchanged
|
||||
charset = utf-8
|
||||
@ -23,9 +22,8 @@ insert_final_newline = true
|
||||
[*.bat]
|
||||
end_of_line = crlf
|
||||
|
||||
[*.java]
|
||||
[*.{java, sh}]
|
||||
indent_size = 4
|
||||
|
||||
[*.md]
|
||||
max_line_length = 0
|
||||
trim_trailing_whitespace = false
|
||||
|
@ -50,7 +50,8 @@ export LANG="zh_CN.UTF-8"
|
||||
|
||||
# 设置全局常量
|
||||
LOG_DIR=/home/zp/log/
|
||||
SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd)
|
||||
SCRIPT_DIR=$(cd "$(dirname "$0")";
|
||||
pwd)
|
||||
SOURCE_DIR=/home/zp/source/
|
||||
APP_NAME=XXX
|
||||
RESOURCES_DIR=/home/zp/source/${APP_NAME}/src/main/resources
|
||||
|
@ -59,7 +59,8 @@ function main(){
|
||||
export LANG="zh_CN.UTF-8"
|
||||
|
||||
# 设置全局常量
|
||||
SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd)
|
||||
SCRIPT_DIR=$(cd "$(dirname "$0")";
|
||||
pwd)
|
||||
SOURCE_DIR=/home/zp/source/
|
||||
APP_NAME=XXX
|
||||
SERVER_ROOT=/home/zp/source/${APP_NAME}/target/
|
||||
|
@ -59,7 +59,8 @@ export LANG="zh_CN.UTF-8"
|
||||
APP=blog
|
||||
LOG_DIR=/home/zp/log
|
||||
SOURCE_DIR=/home/zp/source
|
||||
SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd)
|
||||
SCRIPT_DIR=$(cd "$(dirname "$0")";
|
||||
pwd)
|
||||
|
||||
# 装载函数库
|
||||
. ${SCRIPT_DIR}/helper.sh
|
||||
|
@ -192,7 +192,8 @@ done
|
||||
export LANG="zh_CN.UTF-8"
|
||||
|
||||
# 设置全局常量
|
||||
SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd)
|
||||
SCRIPT_DIR=$(cd "$(dirname "$0")";
|
||||
pwd)
|
||||
SOURCE_DIR=/home/zp/source/
|
||||
|
||||
# 装载函数库
|
||||
|
@ -29,8 +29,10 @@ printf "${RESET}"
|
||||
|
||||
path=/home/scripts/linux-tutorial
|
||||
printf "\n${GREEN}>>>>>>>> Download linux-tutorial to ${path} begin.${RESET}\n"
|
||||
command -v yum >/dev/null 2>&1 || { printf "${RED}Not detected yum.${RESET}"; exit 1; }
|
||||
command -v git >/dev/null 2>&1 || { printf "${YELLOW}Not detected git. Install git.${RESET}\n"; yum -y install git; }
|
||||
command -v yum > /dev/null 2>&1 || { printf "${RED}Not detected yum.${RESET}";
|
||||
exit 1; }
|
||||
command -v git > /dev/null 2>&1 || { printf "${YELLOW}Not detected git. Install git.${RESET}\n";
|
||||
yum -y install git; }
|
||||
|
||||
if [[ -d ${path} ]]; then
|
||||
cd ${path}
|
||||
|
@ -83,7 +83,8 @@ done
|
||||
}
|
||||
|
||||
######################################## MAIN ########################################
|
||||
path=$(cd "$(dirname "$0")"; pwd)
|
||||
path=$(cd "$(dirname "$0")";
|
||||
pwd)
|
||||
printHeadInfo
|
||||
checkOsVersion 0
|
||||
main
|
||||
|
@ -57,4 +57,5 @@ else
|
||||
exit -1
|
||||
fi
|
||||
}
|
||||
|
||||
doInstall
|
||||
|
@ -101,6 +101,7 @@ setPrivilegeForUser() {
|
||||
chown -R elk.elk ${ELASTIC_SOFTWARE_PATH}
|
||||
chown -R elk.elk /var/log/
|
||||
}
|
||||
|
||||
######################################## MAIN ########################################
|
||||
echo -e "\n>>>>>>>>> install elk"
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# auth:kaliarch
|
||||
# version:v1.0
|
||||
# func:elasticsearch 5.4.1/6.0.1/6.3.1安装
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# auth:kaliarch
|
||||
# version:v1.0
|
||||
# func:filebeat 5.6.1/6.1.3/6.3.2 安装
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# auth:kaliarch
|
||||
# version:v1.0
|
||||
# func:kibana 6.0.1/6.2.4/6.3.1 安装
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# auth:kaliarch
|
||||
# version:v1.0
|
||||
# func:logstash 5.4/6.1/6.3 安装
|
||||
|
@ -28,8 +28,10 @@ printf "${RESET}"
|
||||
|
||||
printf "${GREEN}>>>>>>>> install fastdfs begin.${RESET}\n"
|
||||
|
||||
command -v yum >/dev/null 2>&1 || { printf "${RED}Require yum but it's not installed.${RESET}\n"; exit 1; }
|
||||
command -v git >/dev/null 2>&1 || { printf "${RED}Require git but it's not installed.${RESET}\n"; exit 1; }
|
||||
command -v yum > /dev/null 2>&1 || { printf "${RED}Require yum but it's not installed.${RESET}\n";
|
||||
exit 1; }
|
||||
command -v git > /dev/null 2>&1 || { printf "${RED}Require git but it's not installed.${RESET}\n";
|
||||
exit 1; }
|
||||
|
||||
if [[ $# -lt 1 ]] || [[ $# -lt 2 ]]; then
|
||||
printf "${PURPLE}[Hint]\n"
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# auth:kaliarch
|
||||
# version:v1.0
|
||||
# func:grafana 5.1.0/5.1.5/5.2.2 安装
|
||||
|
@ -27,7 +27,8 @@ printf "${RESET}"
|
||||
|
||||
printf "${GREEN}>>>>>>>> install jdk8 begin.${RESET}\n"
|
||||
|
||||
command -v yum >/dev/null 2>&1 || { printf "${RED}Require yum but it's not installed.${RESET}\n"; exit 1; }
|
||||
command -v yum > /dev/null 2>&1 || { printf "${RED}Require yum but it's not installed.${RESET}\n";
|
||||
exit 1; }
|
||||
|
||||
yum -y install java-1.8.0-openjdk-devel.x86_64
|
||||
java -version
|
||||
|
@ -26,7 +26,8 @@ printf "${RESET}"
|
||||
|
||||
printf "${GREEN}>>>>>>>> install kafka begin.${RESET}\n"
|
||||
|
||||
command -v java >/dev/null 2>&1 || { printf "${RED}Require java but it's not installed.${RESET}\n"; exit 1; }
|
||||
command -v java > /dev/null 2>&1 || { printf "${RED}Require java but it's not installed.${RESET}\n";
|
||||
exit 1; }
|
||||
|
||||
if [[ $# -lt 1 ]] || [[ $# -lt 2 ]]; then
|
||||
printf "${PURPLE}[Hint]\n"
|
||||
|
@ -28,7 +28,8 @@ printf "${RESET}"
|
||||
|
||||
printf "${GREEN}>>>>>>>> install maven begin.${RESET}\n"
|
||||
|
||||
command -v java >/dev/null 2>&1 || { printf "${RED}Require java but it's not installed.${RESET}\n"; exit 1; }
|
||||
command -v java > /dev/null 2>&1 || { printf "${RED}Require java but it's not installed.${RESET}\n";
|
||||
exit 1; }
|
||||
|
||||
if [[ $# -lt 1 ]] || [[ $# -lt 2 ]]; then
|
||||
printf "${PURPLE}[Hint]\n"
|
||||
|
@ -26,9 +26,12 @@ printf "${RESET}"
|
||||
|
||||
printf "${GREEN}>>>>>>>> install mysql begin.${RESET}\n"
|
||||
|
||||
command -v wget >/dev/null 2>&1 || { printf "${RED}Require wget but it's not installed.${RESET}\n"; exit 1; }
|
||||
command -v rpm >/dev/null 2>&1 || { printf "${RED}Require rpm but it's not installed.${RESET}\n"; exit 1; }
|
||||
command -v yum >/dev/null 2>&1 || { printf "${RED}Require yum but it's not installed.${RESET}\n"; exit 1; }
|
||||
command -v wget > /dev/null 2>&1 || { printf "${RED}Require wget but it's not installed.${RESET}\n";
|
||||
exit 1; }
|
||||
command -v rpm > /dev/null 2>&1 || { printf "${RED}Require rpm but it's not installed.${RESET}\n";
|
||||
exit 1; }
|
||||
command -v yum > /dev/null 2>&1 || { printf "${RED}Require yum but it's not installed.${RESET}\n";
|
||||
exit 1; }
|
||||
|
||||
# 使用 rpm 安装 mysql
|
||||
wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
|
||||
|
@ -11,8 +11,10 @@ cat << EOF
|
||||
|
||||
EOF
|
||||
|
||||
command -v java >/dev/null 2>&1 || { echo >&2 "Require java but it's not installed."; exit 1; }
|
||||
command -v mvn >/dev/null 2>&1 || { echo >&2 "Require mvn but it's not installed."; exit 1; }
|
||||
command -v java > /dev/null 2>&1 || { echo >&2 "Require java but it's not installed.";
|
||||
exit 1; }
|
||||
command -v mvn > /dev/null 2>&1 || { echo >&2 "Require mvn but it's not installed.";
|
||||
exit 1; }
|
||||
|
||||
if [[ $# -lt 1 ]] || [[ $# -lt 2 ]]; then
|
||||
echo "Usage: sh nacos-install.sh [version] [path]"
|
||||
|
@ -27,7 +27,8 @@ printf "${RESET}"
|
||||
|
||||
printf "${GREEN}>>>>>>>> install maven begin.${RESET}\n"
|
||||
|
||||
command -v yum >/dev/null 2>&1 || { printf "${RED}Require yum but it's not installed.${RESET}\n"; exit 1; }
|
||||
command -v yum > /dev/null 2>&1 || { printf "${RED}Require yum but it's not installed.${RESET}\n";
|
||||
exit 1; }
|
||||
|
||||
if [[ $# -lt 1 ]] || [[ $# -lt 2 ]]; then
|
||||
printf "${PURPLE}[Hint]\n"
|
||||
|
@ -24,7 +24,8 @@ cat << EOF
|
||||
EOF
|
||||
printf "${RESET}"
|
||||
|
||||
command -v yum >/dev/null 2>&1 || { printf "${RED}Require yum but it's not installed.${RESET}\n"; exit 1; }
|
||||
command -v yum > /dev/null 2>&1 || { printf "${RED}Require yum but it's not installed.${RESET}\n";
|
||||
exit 1; }
|
||||
|
||||
if [[ $# -lt 1 ]] || [[ $# -lt 2 ]] || [[ $# -lt 3 ]] || [[ $# -lt 4 ]]; then
|
||||
echo "Usage: sh redis-install.sh [version] [path] [port] [password]"
|
||||
|
@ -27,8 +27,10 @@ printf "${RESET}"
|
||||
|
||||
printf "${GREEN}>>>>>>>> install zsh begin.${RESET}\n"
|
||||
|
||||
command -v yum >/dev/null 2>&1 || { printf "${RED}Require yum but it's not installed.${RESET}\n"; exit 1; }
|
||||
command -v git >/dev/null 2>&1 || { printf "${RED}Require git but it's not installed.${RESET}\n"; exit 1; }
|
||||
command -v yum > /dev/null 2>&1 || { printf "${RED}Require yum but it's not installed.${RESET}\n";
|
||||
exit 1; }
|
||||
command -v git > /dev/null 2>&1 || { printf "${RED}Require git but it's not installed.${RESET}\n";
|
||||
exit 1; }
|
||||
|
||||
# install zsh
|
||||
yum install -y zsh
|
||||
|
@ -127,7 +127,8 @@ done
|
||||
}
|
||||
|
||||
######################################## MAIN ########################################
|
||||
filepath=$(cd "$(dirname "$0")"; pwd)
|
||||
filepath=$(cd "$(dirname "$0")";
|
||||
pwd)
|
||||
|
||||
printHeadInfo
|
||||
main
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
#mail:xuel@anchnet.com
|
||||
#data:2017/9/7
|
||||
#AutoInstall ELK scripts
|
||||
@ -33,6 +34,7 @@ do
|
||||
done
|
||||
clear
|
||||
}
|
||||
|
||||
#initial system:install java wget;set hostname;disable firewalld
|
||||
init_sys() {
|
||||
[ -f /etc/init.d/functions ] && . /etc/init.d/functions
|
||||
@ -161,4 +163,5 @@ check ":5601" "kibana"
|
||||
action "ELK install is success!" /bin/true
|
||||
echo "url:http://$IP:5601"
|
||||
}
|
||||
|
||||
main
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# auth:kaliarch
|
||||
# func:sys info check
|
||||
# version:v1.0
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# function:自定义rm命令,每天晚上定时清理
|
||||
|
||||
CMD_SCRIPTS=$HOME/.rm_scripts.sh
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
#
|
||||
# Daily_Archive - Archive designated files & directories
|
||||
######################################################
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
#
|
||||
# Hourly_Archive - Every hour create an archive
|
||||
######################################################
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
#
|
||||
# Delete_User - Automates the 4 steps to remove an account
|
||||
#
|
||||
@ -16,7 +17,8 @@ function get_answer {
|
||||
do
|
||||
ASK_COUNT=$[ $ASK_COUNT + 1 ]
|
||||
#
|
||||
case $ASK_COUNT in # If user gives no answer in time allowed
|
||||
case $ASK_COUNT in
|
||||
# If user gives no answer in time allowed
|
||||
2)
|
||||
echo
|
||||
echo "Please answer the question."
|
||||
@ -43,7 +45,8 @@ function get_answer {
|
||||
then
|
||||
echo $LINE1 # Print 2 lines
|
||||
echo -e $LINE2" \c"
|
||||
else # Print 1 line
|
||||
else
|
||||
# Print 1 line
|
||||
echo -e $LINE1" \c"
|
||||
fi
|
||||
#
|
||||
@ -56,7 +59,9 @@ function get_answer {
|
||||
unset LINE1
|
||||
unset LINE2
|
||||
#
|
||||
} #end of get_answer function
|
||||
}
|
||||
|
||||
#end of get_answer function
|
||||
#
|
||||
#################################################################
|
||||
function process_answer {
|
||||
@ -79,7 +84,9 @@ function process_answer {
|
||||
unset EXIT_LINE1
|
||||
unset EXIT_LINE2
|
||||
#
|
||||
} #End of process_answer function
|
||||
}
|
||||
|
||||
#End of process_answer function
|
||||
#
|
||||
################################################################
|
||||
#
|
||||
|
@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
current_dir=$(cd `dirname $0`; pwd)
|
||||
current_dir=$(cd `dirname $0`;
|
||||
pwd)
|
||||
echo "当前目录是:${current_dir}"
|
||||
|
||||
parent_dir=$(dirname $(pwd))
|
||||
|
@ -21,6 +21,8 @@ set +x
|
||||
# + (( i < 3 ))
|
||||
# + set +x
|
||||
|
||||
for i in {1..5}; do printf ${i}; done
|
||||
for i in {1..5}; do
|
||||
printf ${i};
|
||||
done
|
||||
printf "\n"
|
||||
# Output: 12345
|
||||
|
@ -28,6 +28,7 @@ calc(){
|
||||
break
|
||||
done
|
||||
}
|
||||
|
||||
calc
|
||||
echo "the result is: $?" # $? 获取 calc 函数返回值
|
||||
# $ ./function-demo.sh
|
||||
|
@ -20,4 +20,5 @@ paramsFunction(){
|
||||
echo "函数第一个入参:$1"
|
||||
echo "函数第二个入参:$2"
|
||||
}
|
||||
|
||||
paramsFunction ${x} ${y}
|
||||
|
@ -19,6 +19,7 @@ paramsFunction(){
|
||||
runner
|
||||
echo "runner 函数的返回值:$?"
|
||||
}
|
||||
|
||||
paramsFunction 1 "abc" "hello, \"zp\""
|
||||
# Output:
|
||||
# 函数第一个入参:1
|
||||
|
@ -1,2 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "Hello, world!"
|
||||
|
@ -20,7 +20,9 @@ done
|
||||
|
||||
################### for in 语句 ###################
|
||||
echo "print 1 to 5"
|
||||
for i in {1..5}; do echo ${i}; done
|
||||
for i in {1..5}; do
|
||||
echo ${i};
|
||||
done
|
||||
# Output:
|
||||
# print 1 to 5
|
||||
# 1
|
||||
|
@ -2,7 +2,9 @@
|
||||
|
||||
################### if 语句 ###################
|
||||
# 写成一行
|
||||
if [[ 1 -eq 1 ]]; then echo "1 -eq 1 result is: true"; fi
|
||||
if [[ 1 -eq 1 ]]; then
|
||||
echo "1 -eq 1 result is: true";
|
||||
fi
|
||||
# Output: 1 -eq 1 result is: true
|
||||
|
||||
# 写成多行
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# send data to the the table in the MYSQL database
|
||||
|
||||
MYSQL=`which mysql`
|
||||
|
@ -1,8 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
#连接数据库
|
||||
mysql=`which mysql
|
||||
`
|
||||
mysql=`which mysql`
|
||||
#发送单个命令
|
||||
$mysql emwjs -u test -e "show databases;"
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
#退出状态码,最大为255,超过则进行模运算
|
||||
#testing the exit status
|
||||
var1=10
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
#An example of using the expr command
|
||||
|
||||
var1=10
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
#using the backtick character 会把反引号里面当作一条命令来执行
|
||||
|
||||
testing=`date`
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
var1=100
|
||||
var2=45
|
||||
var3=`echo "scale=4; $var1 / $var2" | bc`
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
#This script displays the date and who's logged on
|
||||
|
||||
#如果想在同一行显示
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
#display user information from system
|
||||
|
||||
echo "User info fro userId:$USER"
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
#copy the /usr/bin directory listing to a log file
|
||||
|
||||
today=`date +%y%m%d`
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
#使用内建变量
|
||||
|
||||
# NF 当前记录的字段个数
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
#正则表达式
|
||||
|
||||
gawk 'BEGIN{FS=","}
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
#gawk 自定义函数
|
||||
|
||||
gawk '
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
#sed编辑器基础
|
||||
|
||||
#替换标记
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# shell wrapper for sed editor script to reverse lines
|
||||
|
||||
sed -n '{
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
#输出末尾10行数据
|
||||
|
||||
sed '{
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# using the echo to return a value
|
||||
|
||||
function db1 {
|
||||
|
@ -10,7 +10,9 @@ function multem {
|
||||
echo $[ $1 * $2 ]
|
||||
}
|
||||
|
||||
function divem {
|
||||
function divem
|
||||
|
||||
{
|
||||
if [ $2 -ne 0]
|
||||
then
|
||||
echo $[ $1 / $2 ]
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# using select in the menu
|
||||
|
||||
function diskspace {
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# testing STDERR messages
|
||||
|
||||
echo "This is an error " >&2
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# reading data from a file
|
||||
|
||||
count=1
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# simple demonstration of the getopts command
|
||||
|
||||
while getopts :ab:c opt
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# processing options and parameters with getopts
|
||||
|
||||
while getopts :ab:cd opt
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
#extracting command line options and values with getopt
|
||||
# getopt command is not goot at dealing with space,we can use getopts
|
||||
set -- `getopt -q ab:c "$@"`
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# shift n 移动变量
|
||||
|
||||
count=1
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# testing closing file descriptors
|
||||
|
||||
exec 3> test
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# testing inpiut/output file descriptor
|
||||
|
||||
exec 3<> test
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# redirecting input file descriptors
|
||||
|
||||
exec 3>&1
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# getting the number of parameters
|
||||
|
||||
echo There were $# parameters supplied
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# redirecting the inpiut
|
||||
|
||||
# 从test中读取数据,而不是从STDIN中读取数据
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# extracting command line options as parameters
|
||||
|
||||
while [ -n "$1" ]
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# testing $* and $@
|
||||
|
||||
count=1
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# testing STDERR messages
|
||||
# redirecting all to a file
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# testing the $0 parameter
|
||||
|
||||
echo The command entered is $0
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# timing the data entry
|
||||
|
||||
if read -t 5 -p "Please enter your name:" name
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# hiding input data from monitor
|
||||
|
||||
read -s -p "Please enter your password: " pass
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
#
|
||||
# Capture_Stats - Gather System Performance Statistics
|
||||
#
|
||||
|
@ -1,3 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
#
|
||||
uptime | sed 's/user.*$//' | gawk '{print $NF}'
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
#
|
||||
# Report_Stats - Generates Rpt from Captured Perf Stats
|
||||
#
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
#
|
||||
# Snapshot_Stats - produces a report for system stats
|
||||
#
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
#
|
||||
# Update_Problem - updates problem record in database
|
||||
#
|
||||
@ -13,7 +14,8 @@ MYSQL=`which mysql`" Problem_Trek -u root"
|
||||
# Obtain Record Id
|
||||
#
|
||||
if [ $# -eq 0 ] # Check if id number was passed
|
||||
then # If not passed ask for it
|
||||
then
|
||||
# If not passed ask for it
|
||||
#
|
||||
# Check if any unfinished records exist.
|
||||
RECORDS_EXIST=`$MYSQL -Bse 'SELECT id_number FROM problem_logger where fixed_date="0000-00-00" OR prob_solutions=""'`
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
#
|
||||
# Find_Problem - finds problem records using keywords
|
||||
#
|
||||
@ -13,11 +14,13 @@ MYSQL=`which mysql`" Problem_Trek -u root"
|
||||
# Obtain Keyword(s)
|
||||
#
|
||||
if [ -n "$1" ] # Check if a keyword was passed
|
||||
then # Grab all the passed keywords
|
||||
then
|
||||
# Grab all the passed keywords
|
||||
#
|
||||
KEYWORDS=$@ # Grab all the params as separate words, same string
|
||||
#
|
||||
else # Keyword(s) not passed, Ask for them
|
||||
else
|
||||
# Keyword(s) not passed, Ask for them
|
||||
echo
|
||||
echo "What keywords would you like to search for?"
|
||||
echo -e "Please separate words by a space: \c"
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
#
|
||||
# Record_Problem - records system problems in database
|
||||
#
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
#bash shell 仅能处理浮点数值,test命令无法处理val1变量中存储的浮点值
|
||||
|
||||
#testing floating point numbers
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
#continuing an outer loop
|
||||
|
||||
for (( a = 1; a <= 5; a ++ ))
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
#testing the else section
|
||||
testuser=badtest
|
||||
if grep $testuser /etc/passwd
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
#testing the if statement
|
||||
if date
|
||||
then
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
#nesting for loops
|
||||
|
||||
for (( a = 1; a <= 3; a ++ ))
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# using a variable to hold the list
|
||||
|
||||
list="Alabama Alaska Arizona"
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
#reading values from a file
|
||||
|
||||
file="state"
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
#testing the C-style for loop
|
||||
|
||||
for (( i = 1; i <= 10; i ++ ))
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# break n,默认为1
|
||||
|
||||
for (( a = 1; a <= 3; a ++ ))
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
var1=10
|
||||
var2=5
|
||||
if [ $var1 -gt 5 ]
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# using double parenthesis
|
||||
|
||||
var1=10
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# another example of how not to use the for command
|
||||
|
||||
for test in Newada "New Hampshire"
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# using pattern matching
|
||||
|
||||
if [[ $USER == r* ]]
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
#testing compound comparisons
|
||||
|
||||
if [ -d $HOME ] && [ -w $HOME/testing ]
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
#iterate through all the files in a directory
|
||||
for file in /home/tiandi/test/*
|
||||
do
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# testing string length
|
||||
|
||||
#-n 判断长度是否非零
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# multiple variables
|
||||
|
||||
for (( a = 1 , b = 10; a <= 10; a ++ , b -- ))
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
#testing multiple commands in the then section
|
||||
testuser=tiandi
|
||||
if grep $testuser /etc/passwd
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
#testing string equality
|
||||
|
||||
testuser=tiandi
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# checking if a directory or a file exists
|
||||
|
||||
if [ -e $HOME ]
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user