Open8
Linux Knowledge
sed
fileの内容の出力等をいじれるらしい。
例)
1~9行目を削除する
sed '1,9d' sample.txt
1番目に出現した'Linux'を'リナックス'に
sed -e 's/Linux/リナックス/' source.txt
curl で 実行時間とかhttp_status_code とか見たい時
ファイルに出力する時、unixtimeを含める方法
for i in {1..200}; do echo $i; sleep 0.5; curl --insecure --request POST \
--url 'https://account.google.com/login'\
-w "http_code: %{http_code}\ntime_namelookup: %{time_namelookup}\ntime_connect: %{time_connect}\ntime_appconnect: %{time_appconnect}\ntime_pretransfer: %{time_pretransfer}\ntime_starttransfer: %{time_starttransfer}\ntime_total: %{time_total}\n" > Desktop/login_curl_$(date +%s).txt \
--data-raw 'came_from=%2F&email=gmail&password=gmail&form.submitted=Log+In' \
--compressed& done
res=$?
if test "$res" != "0"; then
echo "the curl command failed with: $res"
fi
-w @curl.out で指定すれば次のような出力が得られます。-w @- と、ファイル名を「-」にすれば標準入力から渡すこともできます
$ curl -so /dev/null -w @curl.out https://www.google.com/
content_type: text/html; charset=ISO-8859-1
filename_effective: /dev/null
ftp_entry_path:
http_code: 200
http_connect: 000
local_ip: 172.26.45.140
local_port: 43760
num_connects: 1
num_redirects: 0
redirect_url:
remote_ip: 172.217.25.228
remote_port: 443
size_download: 12618
size_header: 772
size_request: 78
size_upload: 0
speed_download: 98443.000
speed_upload: 0.000
ssl_verify_result: 0
time_appconnect: 0.052
time_connect: 0.004
time_namelookup: 0.001
time_pretransfer: 0.052
time_redirect: 0.000
time_starttransfer: 0.128
time_total: 0.128
url_effective: https://www.google.com/
if 文
curl で直列は xargs -P 1 を付けて同時実行プロセスを1つにできる
作成者以外のコメントは許可されていません