- バックアップ一覧
- 差分 を表示
- 現在との差分 を表示
- ソース を表示
- Bash へ行く。
- 1 (2018-03-18 (日) 20:49:33)
- 2 (2018-03-20 (火) 09:06:21)
- 3 (2019-01-06 (日) 09:24:42)
- 4 (2019-01-12 (土) 21:48:28)
- 5 (2019-01-31 (木) 07:20:51)
- 6 (2019-02-01 (金) 09:43:35)
- 7 (2019-02-02 (土) 09:46:16)
- 8 (2019-02-03 (日) 02:20:06)
- 9 (2019-02-03 (日) 05:36:51)
- 10 (2019-02-04 (月) 05:00:39)
- 11 (2019-02-07 (木) 08:53:49)
- 12 (2019-02-10 (日) 00:28:39)
- 13 (2019-02-10 (日) 03:20:26)
- 14 (2019-02-10 (日) 08:34:09)
- 15 (2019-02-25 (月) 04:44:27)
- 16 (2019-02-25 (月) 08:11:51)
- 17 (2019-02-26 (火) 08:06:29)
- 18 (2019-02-27 (水) 10:02:53)
- 19 (2019-02-28 (木) 09:38:29)
- 20 (2019-03-05 (火) 09:54:13)
- 21 (2019-03-06 (水) 09:17:25)
- 22 (2019-03-07 (木) 07:41:27)
- 23 (2019-03-09 (土) 09:17:38)
- 24 (2019-03-09 (土) 23:41:50)
- 25 (2019-03-10 (日) 07:31:44)
- 26 (2019-03-10 (日) 10:33:46)
- 27 (2019-03-10 (日) 19:16:58)
- 28 (2019-03-17 (日) 07:32:30)
- 29 (2019-03-17 (日) 19:35:17)
- 30 (2019-03-18 (月) 01:12:00)
- 31 (2019-03-22 (金) 07:12:56)
- 32 (2019-03-23 (土) 22:12:31)
- 33 (2019-03-24 (日) 09:14:12)
- 34 (2019-03-26 (火) 08:55:27)
- 35 (2019-03-27 (水) 09:31:09)
- 36 (2019-03-28 (木) 06:30:44)
- 37 (2019-03-29 (金) 09:01:02)
- 38 (2019-03-30 (土) 09:06:01)
- 39 (2019-03-30 (土) 20:22:20)
- 40 (2019-04-01 (月) 08:03:58)
- 41 (2019-04-04 (木) 08:48:41)
- 42 (2019-04-06 (土) 21:07:53)
- 43 (2019-04-11 (木) 06:27:12)
- 44 (2019-05-01 (水) 22:54:09)
- 45 (2019-05-02 (木) 07:50:54)
- 46 (2019-05-02 (木) 19:19:20)
- 47 (2019-05-04 (土) 06:04:16)
- 48 (2019-05-04 (土) 07:35:38)
- 49 (2019-05-06 (月) 07:23:05)
- 50 (2019-07-25 (木) 07:54:44)
- 51 (2020-01-31 (金) 21:32:23)
プロセス置換 †
>(list)
は、ファイルへの出力がlistへの入力となる。<(list)
は、listの出力がファイルへの入力となる。
サンプル lsの結果で*.shファイルのみを出力
# --- commands --- rm "job.done" { sleep 3 && touch job.done; } & retry=0 until [ -f "job.done" ] do sleep 1 ((retry+=1)) if [ $retry -gt 5 ]; then echo "exceeded retry max:5." exit 1 fi done echo "success" # --- output --- success
サンプル a.txtとb.txtをdiffの入力ファイルとして比較
# --- commands --- touch "job.lock" { sleep 3 && rm job.lock; } & retry=0 while [ -f "job.lock" ] do sleep 1 ((retry+=1)) if [ $retry -gt 5 ]; then echo "exceeded retry max:5." exit 1 fi done echo "job done" # --- output --- job done
サンプル
# --- commands --- for w in {localhost,192.168.3.4}; do echo "$w" done # --- output --- localhost 192.168.3.4 # --- commands --- for ((i=0; i < 5;i++)); do echo $i done # --- output --- 0 1 2 3 4
execを使った入出力のリダイレクト †
execコマンドでリダイレクトだけを指定すると、シェル自身のファイル記述子とデバイスの対応を変更することができる。
例 execを使った入力のリダイレクト †
if test-commands; then consequent-commands; [elif more-test-commands; then more-consequents;] [else alternate-consequents;] fi
例 execを使った出力のリダイレクト †
# --- commands --- # Arithmetic expression (( 0 )); echo $? (( 1 )); echo $? #1 ls job.done if ( cd . && test -f job.done ); then echo "job.done found" fi #2 i=0 (( i >= 0 )) ; echo $? if (( i >= 0 )); then echo "i is more than 0" fi #3 i=0 (( (i >= 0) && (i < 1) )) ; echo $? !(( (i >= 0) && (i < 1) )) ; echo $? if !(( (i >= 0) && (i < 1) )); then echo "i is not (i >= 0) && (i < 1)" else echo "i is (i >= 0) && (i < 1)" fi #4 log="FATAL: unexpected error" if [[ "$log" =~ ^FATAL ]]; then echo "Error detected!" fi # --- output --- # Arithmetic expression 1 0 #1 job.done job.done found #2 0 i is more than 0 #3 0 1 i is (i >= 0) && (i < 1) #4 Error detected!
特定の式や文の出力をまとめてリダイレクトしたい場合は、ブレースを使った複合コマンドでも処理できる。
例 複合コマンドの出力をファイルにリダイレクトする
case word in [ [(] pattern [| pattern]…) command-list ;;]… esac