- 追加された行はこの色です。
- 削除された行はこの色です。
[[FrontPage]]
*コマンド
#contents
** bash
# シェル変数一覧
set
# シェル/環境変数解除
unset HOGE
# 拡張子変更
for fn in *.htm; do
mv $fn ${fn%.htm}.html
done
# Ctrl-dでシェルを終了させない
IGNOREEOF=
# 解除
unset IGNOREEOF
# コマンド履歴検索
Ctrl-r
*** 設定ファイルの読み込まれるタイミング
- /etc/profile ログイン時 ~/.bash_profileより前
- ~/.bash_profile ログイン時
- ~/.bash_login ~/.bash_profileが存在しない場合
- ~/.profile ~/.bash_login が存在しない場合
- ~/.bashrc コマンドでbash起動したとき
- ~/.bash_logout ログアウト時
+ ''/etc/profile'' ログイン時 ~/.bash_profileより前
+ ''/etc/profile.d/以下'' /etc/profileにより実行
+ ''~/.bash_profile'' ログイン時
+ ''~/.bash_login'' ~/.bash_profileが存在しない場合
+ ''~/.profile'' ~/.bash_login が存在しない場合
+ ''~/.bashrc'' コマンドでbash起動したとき
+ ''~/.bash_logout'' ログアウト時
*** プロンプト
PS1="HOGE"
- \w カレントディレクトリ
- \W カレントディレクトリのディレクトリ名
- \H ホスト名(フル)
- \h ホスト名
** csh/tcsh
** 特殊キー割り当て
stty erace ^H
** 画面クリア
clear
reset
Ctrl-l
** 絶対パス取得
realpath RELATIVE
** キー入力・画面保存
script FILE
〜
exit
** less
export JLESSCHARSET=euc
jless -K sjis
# tab
less --tab=4
less -x4
# 行番号
less -N
# perldocでESC[が表示されないようにする
perldoc HOGE | less -r
表示中に -x でタブ幅が変更可能
** lv
- 日本語がjlessより賢い
- タブ幅変更不能
** 8/16進表示
# 16
hexdump HOGE
od -h HOGE
# 8
od HOGE
** ls
# 拡張子で並び替え(FreeBSDでは使えないっぽい)
ls -lX
** メモリ使用量を表示
free
** 現在のユーザを表示
# suEXECのテストに使える
whoami
** OSのバージョン
uname -a
** 指定時間に動作
# 追加
at 9:00
# リスト
atq
# 削除
atrm NUM
# 編集
# 分 時間 日 月 曜日 コマンド
crontab -e
# リスト
crontab -l
# 削除
crontab -r
* ファイル色々
** 色付cal
#!/usr/bin/perl
use strict;
my $colorSun = qq|\033[1;31m|;
my $colorSat = qq|\033[1;34m|;
my $colorToday = qq|\033[0;32m|;
my $colorNon = qq|\033[0m|;
my @cal = split(/\n/, `cal`);
my $date = sprintf("%2d", `date +%e`);
foreach my $i (1..$#cal) {
$cal[$i] = sprintf("%-20.20s", $cal[$i]);
$cal[$i] =~ s/^(.{2})(.{16})(.{2})$/$colorSun$1$colorNon$2$colorSat$3$colorNon/gm;
$cal[$i] =~ s/(?=^| )$date(?= |$)/$colorToday$date$colorNon/;
}
my $retval = join("\n",@cal);
print $retval."\n";
** 演習室.bashrc
alias ls='ls -F'
alias ll='ls -la'
alias less='jless'
alias tarc='tar czvf'
alias cal=ccal
export JLESSCHARSET=japanese-jis
export PAGER=jless
export LC_CTYPE=ja_JP.EUC
PS1='
\[\033[0;36m\]\u@\h \[\033[0;37m\]\w\[\033[0m\]
\$ '
export CLICOLOR=xterm-color
export LSCOLORS=exfxcxdxbxegedabagacad
export JSERVER=expwnn7
export MANPATH=$HOME/man:`manpath`
# for enshuD
export PATH=/home/exp/exppub/bin:$PATH
# for fetch
export ftp_proxy=http://cacheserv.ics.es.osaka-u.ac.jp:3128
export http_proxy=http://cacheserv.ics.es.osaka-u.ac.jp:3128
# for ports
export MASTER_SITE_OVERRIDE=ftp://ftp2.jp.FreeBSD.org/pub/FreeBSD/ports/distfiles/
export PORTSDIR=$HOME/ports
export PREFIX=$HOME
export DISTDIR=$HOME/ports/distfiles
# for package
#export PACKAGEROOT=ftp://ftp2.jp.freebsd.org
#export PKG_DBDIR=$HOME/package/pkg_db
** ph .cshrc
umask 22
set path = (/sbin /bin /usr/sbin /usr/bin /usr/games /usr/local/sbin /usr/local/bin /usr/X11R6/bin $HOME/bin)
setenv EDITOR aee
setenv PAGER less
setenv BLOCKSIZE K
setenv CLICOLOR 1
setenv LSCOLORS Exfxcxdxbxegedabagacad
if ($?prompt) then
# An interactive shell -- set some stuff up
set filec
set history = 100
set savehist = 100
set autolist
set autoexpand
set color
set prompt = '%{\033[36m%n@%m%} %{\033[33m%~\033[00m%} \$ '
set mail = (/var/mail/$USER)
if ( $?tcsh ) then
bindkey "^W" backward-delete-word
bindkey -k up history-search-backward
bindkey -k down history-search-forward
endif
endif
source .alias
** Linux .alias
alias h='history 25'
alias j='jobs -l'
alias ls='ls --color=auto -F'
alias la='ls -a'
alias lf='ls -FA'
alias ll='ls -lA'
alias less='jless'
alias tarc='tar czvf'
** FreeBSD .alias
alias h history 25
alias j jobs -l
alias ls ls -G
alias la ls -a
alias lf ls -FA
alias ll ls -lA
alias less jless -Kjapanese-sjis
----
#comment