LoginSignup
15
15

More than 5 years have passed since last update.

便利そうなshellの書き方、linuxコマンドのメモ

Last updated at Posted at 2015-02-11

プロセス名を指定して、プロセスID確認とかkillとか

pgrep -f '<プロセス名>'
pkill -f '<プロセス名>'

参照
http://d.hatena.ne.jp/lurker/20061102/1162427170

文字列の正規表現比較

正規表現は"や'で囲まない!

bash
if [[ $var =~ ^hogehoge$ ]]; then
  ...
fi

参照
http://d.hatena.ne.jp/adsaria/20100107/1262842850

使用しているポートの確認

sudo lsof -i:<port番号>
netstat -anp | grep <port番号>

参照
http://d.hatena.ne.jp/stakizawa/20080324/t1

実行しているシェルファイルが置かれているディレクトリパスを取得

bash
script_dir_path=$(dirname $(readlink -f $0))

参照
http://qiita.com/m-yamashita/items/889c116b92dc0bf4ea7d

15
15
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
15