美文网首页linux toolsOpsDev
Linux命令行与shell脚本编程大全(shell基础)

Linux命令行与shell脚本编程大全(shell基础)

作者: SkTj | 来源:发表于2019-03-01 09:59 被阅读36次

1、if ;then xxx;fi
if ;then elif xx;then xx;else xx;fi
test condition
-eq ge gt le lt ne
str1 = str2
-z
-n 长度非0
-d -e -f -r -s 非空 -w -x -o -G file1 -nt file2 -ot
[]&&[]
[]||[]
case 1 in xx) ;; yy) ;; *) ;; esac for var in xx do xx done IFS=':' for (( i=1;i<10;i++ )) break 终止 break 2 跳出两层循环 continue 2 done >/etc/file 输出重定向# 01 $@

read -t 5 -p "please input your name in 5 seconds" yourname
隐藏输入 read -s -p "Enter your password:" password
从文件中读取
cat file1| while read line
do
echo $line
done
STDIN STDOUT STDERR
2>file1 1>file2
&>file1
列出进程的文件描述符: lsof -a -p 1 -d 0,1,2
-p 指定PID -d 指定文件描述符
/dev/null
创建临时文件:mktemp testing.XXXXXX
mktemp -t testing.XXXXXX
mktemp -d testing.XXXXXX
date|tee file
date|tee -a file

捕获ctrl+c信号:trap "hehehe" SIGINT


image.png

捕获EXIT信号


image.png

nohup bash a.sh &
&& pid

nice -n 10 调整优先级


image.png

at -f a.sh now
at atrm atq
at now + 1 hour
date
ctrl+D

相关文章

网友评论

    本文标题:Linux命令行与shell脚本编程大全(shell基础)

    本文链接:https://www.haomeiwen.com/subject/yfeluqtx.html