質問するログイン新規登録

質問編集履歴

2

\[\]の前後にスペースを追加しました

2017/03/18 04:44

投稿

McKee
McKee

スコア16

title CHANGED
File without changes
body CHANGED
@@ -11,8 +11,8 @@
11
11
  falbum="${fname%_*}"
12
12
  fartist="${fname#*_}"
13
13
 
14
- if [ -e /Users/hoge/radio/file/tmp/${fartist}]; then
14
+ if [ -e /Users/hoge/radio/file/tmp/${fartist} ]; then
15
- if [ -e /Users/hoge/radio/file/tmp/${fartist}/${falbum}]; then
15
+ if [ -e /Users/hoge/radio/file/tmp/${fartist}/${falbum} ]; then
16
16
  mv $f /Users/hoge/radio/file/tmp/${fartist}/${falbum}/
17
17
  else
18
18
  mkdir /Users/hoge/radio/file/tmp/${fartist}
@@ -28,8 +28,6 @@
28
28
 
29
29
  #エラーメッセージ
30
30
  ```
31
- ./Foldering.sh
32
- ./Foldering.sh: line 11: [: missing `]'
33
31
  mkdir: /Users/hoge/radio/file/tmp/hoge: No such file or directory
34
32
  mv: rename ./19900101@hoge_hoge.flv to /Users/hoge/radio/file/tmp/hoge/hoge/: No such file or directory
35
33
  ```

1

コードの部分を灰色にして見やすくしました

2017/03/18 04:44

投稿

McKee
McKee

スコア16

title CHANGED
File without changes
body CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  しかし、実行すると以下のようなエラーメッセージが出てしまい、原因がわかりません。対策として、mkdirの後ろを""で囲んでみたりしましたが同じエラーが出ました。もしよろしければ解決するために皆様の知恵をお貸しいただけないでしょうか。
5
5
  #コード
6
- /usr/bin/bash
6
+ ```/usr/bin/bash
7
7
 
8
8
  find . -name "*.mp3" -type f | while read -r f;do
9
9
  fname="${f%.*}"
@@ -12,21 +12,24 @@
12
12
  fartist="${fname#*_}"
13
13
 
14
14
  if [ -e /Users/hoge/radio/file/tmp/${fartist}]; then
15
- ---if [ -e /Users/hoge/radio/file/tmp/${fartist}/${falbum}]; then
15
+ if [ -e /Users/hoge/radio/file/tmp/${fartist}/${falbum}]; then
16
- ------mv $f /Users/hoge/radio/file/tmp/${fartist}/${falbum}/
16
+ mv $f /Users/hoge/radio/file/tmp/${fartist}/${falbum}/
17
- ---else
17
+ else
18
- ------mkdir /Users/hoge/radio/file/tmp/${fartist}
18
+ mkdir /Users/hoge/radio/file/tmp/${fartist}
19
- ------mkdir /Users/hoge/radio/file/tmp/${fartist}/${falbum}
19
+ mkdir /Users/hoge/radio/file/tmp/${fartist}/${falbum}
20
- ------mv $f /Users/hoge/radio/file/tmp/${fartist}/${falbum}/
20
+ mv $f /Users/hoge/radio/file/tmp/${fartist}/${falbum}/
21
- ---fi
21
+ fi
22
22
  else
23
- ---mkdir /Users/hoge/radio/file/tmp/${fartist}/${falbum}/
23
+ mkdir /Users/hoge/radio/file/tmp/${fartist}/${falbum}/
24
- ---mv $f /Users/hoge/radio/file/tmp/${fartist}/${falbum}/
24
+ mv $f /Users/hoge/radio/file/tmp/${fartist}/${falbum}/
25
25
  fi
26
26
  done
27
+ ```
27
28
 
28
29
  #エラーメッセージ
30
+ ```
29
31
  ./Foldering.sh
30
32
  ./Foldering.sh: line 11: [: missing `]'
31
33
  mkdir: /Users/hoge/radio/file/tmp/hoge: No such file or directory
32
- mv: rename ./19900101@hoge_hoge.flv to /Users/hoge/radio/file/tmp/hoge/hoge/: No such file or directory
34
+ mv: rename ./19900101@hoge_hoge.flv to /Users/hoge/radio/file/tmp/hoge/hoge/: No such file or directory
35
+ ```