2014-11-26 Wed

ShellCheck はてぶ

メモ

https://github.com/koalaman/shellcheck

便利そうだけど、Haskell なので、Solaris に入れにくい。

Fedora はパッケージがあるので、yum install ShellCheck で入る。

Solaris は @karky7 先生が ghc 関連のパッケージをいい感じにしてくれるの待ち。

via: シェルスクリプトを簡単にチェックできるShellCheck, Vimでも使える - rcmdnk’s blog
     http://rcmdnk.github.io/blog/2014/11/26/computer-bash-zsh/

2010-02-08 Mon

date を使って目的の日までの残り日数を計算する はてぶ

- How many days until the end of the year | commandlinefu.com
  http://www.commandlinefu.com/commands/view/4804/how-many-days-until-the-end-of-the-year
から,今年の残り日数.

echo "There are $(($(date +%j -d"Dec 31, $(date +%Y)")-$(date +%j))) left in year $(date +%Y)."
echo "There are $(($(date +%j -d"Dec 31")-$(date +%j))) left in year $(date +%Y)."
echo "There are $(($(date +%j -d"Dec 31")-$(date +%-j))) left in year $(date +%Y)."


1 つめの date の引数を目的の日付にすればよい.

%j は年内通算日数を表す日付フィールド

$ date +%j -d"Dec 31 2010"
365
$ date +%j -d"Dec 31 2008"
366


日付フィールドのハイフンはパディングの制御

$ date +%j -d"Feb 08"
039
$ date +%-j -d"Feb 08"
39


- n 日前の日付けを求める [2005-09-30-6]

2009-07-22 Wed

シェルの変数 はてぶ

- シェルの変数に慣れる
  http://www.atmarkit.co.jp/flinux/rensai/shell05/parameter.html

直前に実行したコマンドのステータス "$?" をよく忘れるのでメモ.

2009-05-29 Fri

byobu で GNU screen の status line を派手にする はてぶ

- byobu in Launchpad
  https://launchpad.net/byobu

byobu 自体は screen の設定などをするプログラムだけど,
.deb しか用意されていないため,他の環境では,
byobu-export.tar.gz を使う.

byobu については
- Ubuntu Weekly Recipe:第72回 screen-profiles("byobu")を使う|gihyo.jp
  http://gihyo.jp/admin/serial/01/ubuntu-recipe/0072
を参照.
[ Read More... ]

2007-11-21 Wed

GNU screen でエンコーディングの切り替え はてぶ

設定したことを忘れてたのでメモ.

bind 'U' eval "encoding utf8" "stuff 'export LANG=ja_JP.UTF-8\012'"
bind 'E' eval "encoding euc" "stuff 'export LANG=ja_JP.EUC-JP\012'"


- UTF-8 環境 (2)
  http://d.hatena.ne.jp/babie/20051222

Referrer (Inside):
[2009-05-29-2] byobu で GNU screen の status line を派手にする

2007-09-21 Fri

zsh に移行して 1 年経ってた はてぶ

1 年経ったものの,zsh の特徴を生かした使い方をしているとは
言えないのが微妙.

- zsh を使い始めてみる [2006-09-20-2]

2006-11-08 Wed

sgtd - Simply Getting Things Done はてぶ

http://waxandwane.org//sgtd/view.cgi

Technically, it is implemented in the C language using SQLite for database storage and the ncurses library for a simple, clutter free user interface.

あとで試す

とりあえず,インストールだけはしてみた.

2006-11-07 Tue

diffの結果をvimで色付けして表示するグローバルエイリアス はてぶ

http://d.hatena.ne.jp/ysano2005/20061102/1162445347

zsh のグローバルエイリアス + 一時ファイル

# View command results(stdout) by vim
export VIM_TMP=/tmp/vim.tmp
alias -g V="> $VIM_TMP$$; vim $VIM_TMP$$"


使い方は

% svn diff V
% diff -u Makefile.in.orig Makefile.in V




ColorDiff

- ColorDiff
  http://colordiff.sourceforge.net/



zsh のグローバルエイリアス(一時ファイルなし)

alias -g V="| vim -R -"




less.sh + less.vim

- spiritlooseのはてなダイアリー - ページャでsyntax highlight
  http://d.hatena.ne.jp/spiritloose/20061103/1162525712



zsh のプロセス置換

% vim =(diff fileA fileB)


2006-11-05 Sun

pgrep, pkill を使用してプロセスを殺す はてぶ

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

$ pgrep -f emacs
357
374
$ pgrep -fl emacs
357 emacs
374 /usr/bin/ruby -S migemo -t emacs -i  -u /home/fumi/.migemo-user-dict -d /usr/share/migemo/migemo-dict
$ pgrep -l emacs
357 emacs


"-f" プロセスの引数もマッチ対象にする
"-l" プロセス名を表示

ps ax | grep emacs


とすると,grep emacs のプロセスがひっかかるが,
pgrep では pgrep emacs のプロセス自身がひっかかることはない.

2006-09-27 Wed

コマンド使用率ランキング はてぶ

zsh は

% perl -pe 's/.+;//' ~/.zsh-history | sort | uniq -c | sort -r|head -12


で集計.

zsh は使い始めたばかり [2006-09-20-2] で,

$ wc -l .zsh-history
316 .zsh-history


と履歴が少ないので,bash の履歴を調べてみた.

$ sort < ~/.bash_history |uniq -c |sort -nr |head
   1659 ls
    998 exit
    544 cl-local
    511 screen -r
    264 su -
    263 screen emacs
    258 cd
    243 ps ax
    228 df -h
    217 cd


cd が 2 個あるけど,これは "cd" か "cd " の違いみたい.

気になるなら

$ sed -e 's/ *$//' < .bash_history |sort |uniq -c |sort -nr |head


で行末のスペースを落とせばいい.

via: コマンド使用率ランキング
     http://www.pochi.cc/~sasaki/chalow/2006-09-27-9.html

2006-09-20 Wed

zsh を使い始めてみる はてぶ

bash から移行してみる.

Referrer (Inside):
[2007-09-21-1] zsh に移行して 1 年経ってた
[2006-09-27-1] コマンド使用率ランキング

2006-08-15 Tue

Value Domain の DDNS 用手抜きスクリプト はてぶ

#!/bin/sh

domain="ftnk.jp"
passwd="foobar"

logfile="$HOME/tmp/VDupdate.log"
ipfile="$HOME/tmp/VDupdate.ip"

ip=`/sbin/ifconfig ppp0 | sed -n "s/.*inet addr:\([^ ]*\).*/\1/p"`
url="http://dyn.value-domain.com/cgi-bin/dyn.fcg?d=$domain&p=$passwd&h=*&i=$ip"

if [ -e $ipfile ]
then
    if [ "$ip" != `cat $ipfile` ]
    then
	res=`/usr/bin/w3m -dump $url`
    else
	res="IP not changed"
    fi
fi

echo `date "+%Y-%m-%d %T"` $ip $res >> $logfile
echo $ip > $ipfile


これで大丈夫なはず(未確認).

2006-04-20 Thu

文字形式を逆順に表示する tac がないので はてぶ

http://www.ki.nu/~makoto/diary/?200604b#200604202

tac なんてコマンド知らなかった.

2006-03-19 Sun

ssh 公開鍵を登録するシェルスクリプト はてぶ

http://tabesugi.net/memo/2006/32.html#180010

2006-03-02 Thu

GNU screen の status line を変更 はてぶ

GNU screen の status line に表示される active な window の背景色を変えるように変更.

hardstatus alwayslastline "%H[%n]: %Y-%m-%d %c [%-w%{=b cb}%n %t%{-}%+w]"


2006-03-02 Thu

Funny UNIX Shell Commands はてぶ

http://www.csd.uwo.ca/staff/magi/personal/humour/Computer_Audience/
Funny%20UNIX%20Shell%20Commands.html

% make love
Make: Don't know how to make love. Stop.


といった類のネタ.

2006-02-11 Sat

シェルスクリプトを走らせているあいだに書きかえる方法 はてぶ

http://tabesugi.net/memo/cur/cur.html#091536

$ mv running.sh running.sh.old
$ cp running.sh.old running.sh
$ vi running.sh



mv しても sh の握っている i node は変わらないので,
こういうことができるらしい.

$ touch foo.txt
$ ls -i
25125952 foo.txt
$ mv foo.txt bar.txt
$ ls -i
25125952 bar.txt


2006-01-26 Thu

awk の代りに cut を使う はてぶ

http://www.ki.nu/~makoto/diary/?200601c#200601262

awk -F/ '{print $2}'
cut -d '/' -f 2


awk の FS の指定って -F でできたのか.

2005-12-18 Sun

GNU screen,emacs 風 keybind はてぶ

http://subtech.g.hatena.ne.jp/secondlife/20051216/1134741917

bind -c REGION 2 split
bind -c REGION 1 only
bind -c REGION 0 remove
bind -c REGION o focus
bind -c REGION \^ resize
bind x command -c REGION


Referrer (Inside):
[2009-05-29-2] byobu で GNU screen の status line を派手にする
ChangeLog 最新ページ / カテゴリ最新ページ / 1 2 / page 1 (2)