カテゴリ
HTML PostgreSQL linux

【シェルスクリプト】sedコマンドを使った文字列置換

文字列置換 使い方「sed 's/置換前/置換後/'」 1行ごとに最初に見つかった置換対象を置換する echo abc | sed 's/a/b/' #結果:bbc echo abcabc | sed 's/a/b/' #結果:bbcabc 置換対象を全て置換するには「g」を付ける echo abcabc | sed 's/a/b/g' #結果:bbc…

【PHP】文字コード表示プログラム

シェルスクリプトで作成したこちらをPHPでも作成 taiskill.com 変数「xxx」に入れた文字列を各文字コードに変換して表示する

【シェルスクリプト】文字コード表示プログラム

変数「xxx」に入れた文字列を各文字コードに変換して表示する #!/bin/bash xxx="あ" enc=("default" "UTF-8" "SHIFT-JIS" "EUC-JP" "ASCII") display() { echo "String \"${1}\" in ${2}:" if [ "${2}" = "default" ]; then echo "${1}" | od -An -tx1 else …

【linux】ディレクトリ毎のファイル数をカウントする

ディレクトリ毎のファイル数をカウントする 実行したカレントディレクトリ下が対象になる for d in `find . -type d`; do echo $d,`ls "$d" | wc -l`; done 場所を変更したい場合は、ディレクトリ移動するか、find後の「.」パスを変更する

【PostgreSQL】カラム名検索

カラム名で検索したい時は以下のようにする select table_name, column_name from information_schema.columns where column_name ='カラム名'; 登録したデータがどこに入っているのか分からない時は以下のようにする pg_dump --data-only --inserts -U post…

【PostgreSQL】insert文の使い方

テーブルにデータを複数作りたい時に使えるinsert文 例)testテーブル id title 1 title1 2 title2 通常のinsert文 insert into test(id,title) values('3','title3'); valuesはカンマ区切りで繋げることができる insert into test(id,title) values('3','ti…

【PHP】file_put_contentsの活用

調査する時に、file_put_contentsを使う file_put_contents('/var/tmp/test.txt', $test . "¥n", FILE_APPEND); // 「var/tmp/test.txt」に「$test . "¥n"」を「FILE_APPEND」(追記)する file_put_contents('/var/tmp/test.txt', __FILE__ . " " . __LINE_…