Quantcast
Channel: Bashタグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 2912

curlで -bash: -o: command not found

$
0
0

curlコマンドにはファイル保存する-oオプションがありますが、urlに&があるとshellのバックグラウンドプロセス実行として解釈されてしまい意図通りに動かない。(バックグラウンド処理されるだけなので標準出力に結果は表示される)

動かない例
$ curl https://www.googleapis.com/books/v1/volumes?q=search+%E6%8A%80%E8%A1%93&maxResults=10 -o result.json
[1] 2950
-bash: -o: command not found

&をエスケープするかurlをクォーテーションで囲むことで解決できる

動く例
$ curl "https://www.googleapis.com/books/v1/volumes?q=search+%E6%8A%80%E8%A1%93&maxResults=10" -o result.json

Viewing all articles
Browse latest Browse all 2912

Trending Articles