シェルスクリプト総合 その25at UNIXシェルスクリプト総合 その25 - 暇つぶし2ch■コピペモード□スレを通常表示□オプションモード□このスレッドのURL■項目テキスト26:名無しさん@お腹いっぱい。 15/08/25 09:55:00.50 .net そうでもないよ $ cat test.sh #!/bin/sh for f in "$1"/* do echo "$f" done $ touch "space ship.txt" $ sh test.sh . ./space ship.txt ./test.sh 27:名無しさん@お腹いっぱい。 15/08/25 11:38:42.71 .net >>24 、>>25 と同様そうでもない 対象ディレクトリと対象ディレクトリ内のファイル名の両方にスペースが含まれて いても問題ない あと、ソースに渡された引数+"/*"がどう展開されるかの表示を追加 bash-2.05$ cat test.sh #!/bin/sh echo -n "arg/* = '" echo -n "${1}"/* echo "'" echo for file in "${1}"/* do echo "${file}" done exit 0 28:26 15/08/25 11:40:11.64 .net bash-2.05$ mkdir "foo bar" bash-2.05$ cd "foo bar" bash-2.05$ touch "space ship.txt" bash-2.05$ touch space_ship.txt bash-2.05$ cd .. bash-2.05$ tree `-+ . +-- foo bar | +-- space ship.txt | +-- space_ship.txt +-- test.sh 1 directory 3 files bash-2.05$ sh test.sh "foo bar" arg/* = 'foo bar/space ship.txt foo bar/space_ship.txt' foo bar/space ship.txt foo bar/space_ship.txt bash-2.05$ 次ページ最新レス表示レスジャンプ類似スレ一覧スレッドの検索話題のニュースおまかせリストオプションしおりを挟むスレッドに書込スレッドの一覧暇つぶし2ch