echo 'helloworld'
echo '请输入:'
read name
echo '你输入的是:' $name
ls
cat package.json
touch test.sh
echo test > test.sh
rm test.sh
cd src
Return to the upper floor
cd ..
mv name1 name2
sudo chmod -R 777 .
docker rmi $(docker images | grep "<none>" | grep -oE "[0-9a-z]{12}" | tr '\n' ' ')
Description: docker images lists the images, grep none filters out the rows of the none images, then regularly extracts the image id, combines each line into a line with the tr command to separate spaces, and finally uses the rmi command to delete the filtered none image id
tail -f -n 10 logs/nest:09-16.log
cat yarn.lock | grep -oE -A1 "^react@\S+"
Note: cat < file > can output the file content to the terminal, grep can filter each line of the terminal content,-o means only output matching content,-E means using extended regular,-A means that the output contains the next few lines, for example, A1 will contain the next line.
function verify_arg {
if [ "$2" = "" ]; then
echo "$1 is required: $2"
exit
else
echo $2
fi
}
verify_arg "entry" $entry
Multiple lines:
if [[ "$entry" = "123" ]]; then
echo $entry
else
echo "test"
exit
fi
Single line:
# exit 0 正常退出,exit 1 异常退出
[[ {{ .beta }} == true ]] && echo "skip register entry in beta." && exit 0
ls -d */
-v reverse election
ls -d */ | grep -v "blog" # 排除含有blog的
ls -d */ | grep -v "blog" | xargs -I {} cp -r ./{} ./blog/{}
placeholder {}
declares a placeholder {} to receive the previous value, followed by a command to replace the symbol
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