タグ

関連タグで絞り込む (1)

タグの絞り込みを解除

bashとunixに関するa_bickyのブックマーク (3)

  • Multiple variable assignments from command output in BASH Using date, read

    It's quite easy to capture the output of a command and assign it in a shell's variable: day=$(date +%d) month=$(date +%m) But, what if we want to perform the same task with just one program invocation? Here comes the power of eval! date(1) outputs a string like "day=29; month=07; year=11" (notice the semicolons I added on purpose at date's custom output) which is a legal shell line. This like is t

    a_bicky
    a_bicky 2012/01/25
    bash で read day month year <<< $(date +'%d %m %y') みたいにすると同時に変数を定義できるとか驚愕
  • Exit Codes With Special Meanings

    Table E-1. Reserved Exit Codes Exit Code NumberMeaningExampleComments

    a_bicky
    a_bicky 2012/01/20
    一般的な exit status の意味
  • UNIXシェルスクリプトメモ(Hishidama's UNIX shell script Memo)

    -xを付けると実行内容を表示しながら実行する。[2008-11-29] bash -x スクリプトファイル -nを付けると、実行せずにファイル内の構文解析(エラーの有無のチェック)を行う。[2008-11-29] bash -n スクリプトファイル . スクリプトファイル 現在実行中のシェルと同じシェルを使ってスクリプトを実行する。 スクリプトの中で環境変数を設定した場合、現在のシェルの環境にも影響する (スクリプトの中で定義した環境変数が実行元でも有効になる)。 ファイルに実行権限(chmod +x)が付いている場合は、以下のようにして実行できる(相対パスで指定している)。 ./スクリプトファイル ファイルに実行権限(chmod +x)が付いており、かつ環境変数PATHにカレントディレクトリ「.」が含まれている場合は、以下のようにして実行できる。 スクリプトファイル シェルスクリプトの書

  • 1