Skip to content

Instantly share code, notes, and snippets.

@ponsuke0531
Last active April 20, 2020 09:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ponsuke0531/a1908e5ad776a5648b0bf02d9d13a64e to your computer and use it in GitHub Desktop.
Save ponsuke0531/a1908e5ad776a5648b0bf02d9d13a64e to your computer and use it in GitHub Desktop.
bashでshellを作るとき参考になるサイト集 ref: https://qiita.com/ponsuke0531/items/a56126b8b218f74faa10
# -n "${line}" で最終行が空行でない場合にも対応する
cat {ファイル名} | while read line || [ -n "${line}" ]; do
# 1行($line)ずつ処理する
done
$ bash {ファイル名}.sh
# 1行のコメント
<< '#_comment_'
複数行のコメント
_comment_
$ bash {ファイル名}.sh
str1=pon
str2=suke
# 並べる
echo $str1$str2 # >> ponsuke
# 並べる(ダブルクォーテーション版)
echo "なまえは、{$str1}{$str2}" # >> なまえは、ponsuke
# 追加する
name=''
name+=str1
name+=str2
echo $name # >> ponsuke
$ bash {ファイル名}.sh
小文字にする
${変数,,}
$ bash {ファイル名}.sh
$ bash {ファイル名}.sh
#!/bin/bash
# ↑これは「しぇばん」というそうです。
# <-1行のコメントはこれです。
<< '#_comment_'
複数行のコメント
_comment_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment