その他
先日、apt-getでupgradeした後、Ubuntuにログインできなくなったため対処法を記録。GUIのログイン画面からパスワードを入れてEnterを押すと、再度ログイン画面に戻ってくるという現象です。.Xauthorityを消すなども試してみましたが効果がなく、どうもNvidia…
a.txtが以下の形式だとする apple grape orange apple、grape、orangeごとに処理を変えたい場合、以下のようにする。 cat a.txt | while read -r f; do echo $f done 上のスクリプトの結果は単純に"cat a.txt"と同じだが、 catの部分でawkを使ったりするとい…
以下のa.txtとb.csvがあった場合を考える。a.txt apple grape orange b.txt apple 100 JPY apple 1 USD orange 98 JPY banana 50 JPY peach 268 JPY以下のスクリプトでa.txtに載っているアイテムだけ抽出する cat a.txt | while read -r f; do awk -v item="…
CSVの行(文字列)を要素ごとに分割してvectorで受け取る。 vector<string> split(string str, char c){ vector<string> v; string buf = ""; stringstream ss; ss << str; while (getline(ss, buf, c)){ v.push_back(buf); } return v; } サンプルコード #include <iostream> #include <string></string></iostream></string></string>…