Last active
April 20, 2020 09:40
-
-
Save ponsuke0531/a1908e5ad776a5648b0bf02d9d13a64e to your computer and use it in GitHub Desktop.
bashでshellを作るとき参考になるサイト集 ref: https://qiita.com/ponsuke0531/items/a56126b8b218f74faa10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -n "${line}" で最終行が空行でない場合にも対応する | |
cat {ファイル名} | while read line || [ -n "${line}" ]; do | |
# 1行($line)ずつ処理する | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ bash {ファイル名}.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1行のコメント | |
<< '#_comment_' | |
複数行のコメント | |
_comment_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ bash {ファイル名}.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
str1=pon | |
str2=suke | |
# 並べる | |
echo $str1$str2 # >> ponsuke | |
# 並べる(ダブルクォーテーション版) | |
echo "なまえは、{$str1}{$str2}" # >> なまえは、ponsuke | |
# 追加する | |
name='' | |
name+=str1 | |
name+=str2 | |
echo $name # >> ponsuke |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ bash {ファイル名}.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
小文字にする | |
${変数,,} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ bash {ファイル名}.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ bash {ファイル名}.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# ↑これは「しぇばん」というそうです。 | |
# <-1行のコメントはこれです。 | |
<< '#_comment_' | |
複数行のコメント | |
_comment_ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment