bash cheat sheet

132 阅读1分钟

pwd 查看路径

bash --version 查看bash当前版本

echo hello world

  • echo 输出多行文本需要把多行文本放到引号里面
  • echo -n hello world // 输出末尾不加换行符

短路逻辑依旧存在 && ||

type 判断内部外部命令

  • type echo // echo is a shell builtin
  • type ls // ls is hashed (/bin/ls)

ctrl-L 替代 clear

ls ?.txt 匹配单名的txt文件

stat 是加强版的ls

touch 创建空文件

cat 显示文本的文件内容

#!/usr/bin/env sh

# 当发生错误时中止脚本
set -e

# 构建
npm run build

# cd 到构建输出的目录下
cd dist

# 部署到自定义域域名
# echo 'www.example.com' > CNAME

git init
git add -A
git commit -m 'deploy'

# 部署到 https://<USERNAME>.github.io
# git push -f git@github.com:<USERNAME>/<USERNAME>.github.io.git master

# 部署到 https://<USERNAME>.github.io/<REPO>
 git push -f git@github.com:ryanchosen/diandi-financials-demo.git master:gh-pages

cd -
npm run build &&
git checkout github-pages &&
rm -rf src *.sh *.js *.json &&
mv dist/* ./ &&
rm -rf dist &&
git add . &&
git commit -m 'update' &&
git push &&
git checkout -