echo 'helloworld'
echo '请输入:'
read name
echo '你输入的是:' $name
ls
cat package.json
touch test.sh
echo test > test.sh
rm test.sh
cd src
返回上一层
cd ..
mv name1 name2
sudo chmod -R 777 .
docker rmi $(docker images | grep "<none>" | grep -oE "[0-9a-z]{12}" | tr '\n' ' ')
说明:docker images列出镜像,grep none过滤出none镜像的行,然后正则提取镜像id,用tr命令将每一行组合到一行上空格分隔,最后使用rmi命令删除过滤好的none镜像id
tail -f -n 10 logs/nest:09-16.log
cat yarn.lock | grep -oE -A1 "^react@\S+"
说明:cat
function verify_arg {
if [ "$2" = "" ]; then
echo "$1 is required: $2"
exit
else
echo $2
fi
}
verify_arg "entry" $entry
多行:
if [[ "$entry" = "123" ]]; then
echo $entry
else
echo "test"
exit
fi
单行:
# exit 0 正常退出,exit 1 异常退出
[[ {{ .beta }} == true ]] && echo "skip register entry in beta." && exit 0
ls -d */
-v 反选
ls -d */ | grep -v "blog" # 排除含有blog的
ls -d */ | grep -v "blog" | xargs -I {} cp -r ./{} ./blog/{}
xargs -I {}
声明一个占位符号{}接收前面的值,后面的命令替换符号
find ./blog -type f -not -name "*.md" | xargs -I {} rm -rf {}
find ./blog -type d -empty | xargs -n 1 rm -rf
find . | awk '{print substr($0, 3)}' # 取每行第3个字符后的
[[ $(grep -c build ./package.json) != 0 ]] && yarn run build
ls -A1 | xargs rm -rf