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

質問編集履歴

2

比較演算子の訂正

2020/02/07 08:34

投稿

yuuyu
yuuyu

スコア1139

title CHANGED
File without changes
body CHANGED
@@ -60,7 +60,7 @@
60
60
  u='/Users/username/folder/css/file.css'
61
61
  for co in {1..35}
62
62
  do
63
- if [${f:co:1} -eq ${u:co:1}]; then
63
+ if [${f:co:1} = ${u:co:1}]; then
64
64
  echo $co"equal {"${f:co:1}"="${u:co:1}"}"
65
65
  else
66
66
  echo $co"not equal {"${f:co:1}"="${u:co:1}"}"

1

追記の記述

2020/02/07 08:34

投稿

yuuyu
yuuyu

スコア1139

title CHANGED
File without changes
body CHANGED
@@ -48,4 +48,31 @@
48
48
  Mac os 15.10.2(Catalina)
49
49
  Automator 2.10
50
50
  YuiCompressor [https://github.com/yui/yuicompressor/releases](https://github.com/yui/yuicompressor/releases)
51
- シェルスクリプト参考サイト [https://ameblo.jp/itboy/entry-12259677966.html](https://ameblo.jp/itboy/entry-12259677966.html)
51
+ シェルスクリプト参考サイト [https://ameblo.jp/itboy/entry-12259677966.html](https://ameblo.jp/itboy/entry-12259677966.html)
52
+
53
+
54
+ ###追記
55
+ Automatorで以下のコードを実行してみました。
56
+ ```sh
57
+ #!/bin/bash
58
+ for f in "$@"
59
+ do
60
+ u='/Users/username/folder/css/file.css'
61
+ for co in {1..35}
62
+ do
63
+ if [${f:co:1} -eq ${u:co:1}]; then
64
+ echo $co"equal {"${f:co:1}"="${u:co:1}"}"
65
+ else
66
+ echo $co"not equal {"${f:co:1}"="${u:co:1}"}"
67
+ fi
68
+ done
69
+ fi
70
+ done
71
+ ```
72
+ 実行結果ですが、
73
+ 「1not equal{U=U}」
74
+ 「2not equal{s=s}」
75
+ (以下略)
76
+
77
+ となりました。文字コードが異なるのが原因ということになるのでしょうか?
78
+ ただ文字コードの修正方法は未だわかっていないので、もう少し調べてみることにします。