$()の括弧の中でコマンドを記述すれば,その結果を変数として取得できる. script$ cat cmd-str.sh #!/bin/bash val=$(pwd) echo "results of pwd = ${val}" 上記のスクリプトでは,pws コマンドの実行結果を変数 val に格納して,echo で出力している. 実行すると・・・ script$ bash cmd-str.sh results of pwd = /home/akito/script という結果になる. lsコマンドを利用すればファイルやディレクトリのリストを変数に格納できるし,grepした結果を格納することも可能