古い tail(1) では、指定行から最後まで表示する際に +行数 を用いていたが、
最新のものでは、-n を用いる。若しくは _POSIX2_VERSION=199209 で後方互換を指示。
$ cat -n /etc/httpd/conf/httpd.conf | tail -2 1017 # CustomLog logs/dummy-host.example.com-access_log common 1018 # $ cat -n /etc/httpd/conf/httpd.conf | tail +1000 tail: `+1000' を 読み込み用でオープンできません: そのようなファイルや ディレクト リはありません $ cat -n /etc/httpd/conf/httpd.conf | tail -n +1000 1000 # 1001 # NOTE: NameVirtualHost cannot be used without a port specifier : 1018 # $ export _POSIX2_VERSION=199209 $ cat -n /etc/httpd/conf/httpd.conf | tail +1000 1000 # 1001 # NOTE: NameVirtualHost cannot be used without a port specifier : 1018 #
$ head nl.txt |cat -n 1 NL(1) User Commands 2 3 4 5 NAME 6 nl - number lines of files 7 8 SYNOPSIS 9 nl [OPTION]... [FILE]... 10 $ head nl.txt |nl 1 NL(1) User Commands 2 NAME 3 nl - number lines of files 4 SYNOPSIS 5 nl [OPTION]... [FILE]...
sort(1) も tail(1) 同様に、検索位置は -k オプションを伴う。
-k +開始位置 [,-終了位置]。若しくは _POSIX2_VERSION=199209 で後方互換を指示。
$ sort -t: -k 3 -r /etc/passwd | head news:x:9:13:news:/etc/news: nobody:x:99:99:Nobody:/:/sbin/nologin dovecot:x:97:97:dovecot:/usr/libexec/dovecot:/sbin/nologin distcache:x:94:94:Distcache:/:/sbin/nologin mail:x:8:12:mail:/var/spool/mail:/sbin/nologin postfix:x:89:89::/var/spool/postfix:/sbin/nologin dbus:x:81:81:System message bus:/:/sbin/nologin halt:x:7:0:halt:/sbin:/sbin/halt pcap:x:77:77::/var/arpwatch:/sbin/nologin sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin $ sort -t: -k 3 -rn /etc/passwd | head nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin student01:x:505:505::/home/student01:/bin/bash samboa:x:504:504::/home/samboa:/bin/bash n-shintani:x:503:503::/home/n-shintani:/bin/bash ycos:x:502:502::/home/ycos:/bin/bash student:x:501:501::/home/student:/bin/bash user:x:500:500:SAMBOA USER:/home/user:/bin/bash clam:x:104:106:Clam Anti Virus Checker:/var/lib/clamav:/sbin/nologin amavis:x:103:105:Amavis email scan user:/var/amavis:/bin/sh clamav:x:102:104:Clam Anti Virus Checker:/var/clamav:/sbin/nologin
$ sort simple.txt aaaaa aaaaa aaaaa aaaaa bbbbb bbbbb ccccc ccccc $ sort simple.txt | uniq aaaaa bbbbb ccccc $ sort simple.txt | uniq -c 4 aaaaa 2 bbbbb 2 ccccc
$ cut -d: -f1,6,3 /etc/passwd | head root:0:/root bin:1:/bin daemon:2:/sbin adm:3:/var/adm lp:4:/var/spool/lpd sync:5:/sbin shutdown:6:/sbin halt:7:/sbin mail:8:/var/spool/mail news:9:/etc/news
$ paste a.txt b.txt
1 aaaaa 2 bbbbb 3 ccccc 4 ddddd |
1 AAAAA 3 CCCCC 5 DDDDD |
1 3 |
aaaaa ccccc |
AAAAA CCCCC |
$ pr /etc/httpd/conf/httpd.conf | head 2014-02-08 12:26 /etc/httpd/conf/httpd.conf Page 1 # # This is the main Apache server configuration file. It contains the # configuration directives that give the server its instructions. # See <URL:http://httpd.apache.org/docs/2.2/> for detailed information. # In particular, see
$ fmt /etc/httpd/conf/httpd.conf | head # # This is the main Apache server configuration file. It contains the # configuration directives that give the server its instructions. # See <URL:http://httpd.apache.org/docs/2.2/> for detailed information. # In particular, see # <URL:http://httpd.apache.org/docs/2.2/mod/directives.html> # for a discussion of each configuration directive. # # # Do NOT simply
:set all --- オプション --- aleph=224 foldclose= mousetime=500 switchbuf= noarabic foldcolumn=0 nonumber synmaxcol=3000 arabicshape foldenable numberwidth=4 syntax= noallowrevins foldexpr=0 omnifunc= tabline= noaltkeymap foldignore=# operatorfunc= tabpagemax=10 ambiwidth=single foldlevel=0 nopaste tabstop=8 noautochdir foldlevelstart=-1 pastetoggle= tagbsearch noautoindent foldmethod=manual patchexpr= taglength=0 noautoread foldminlines=1 patchmode= tagrelative noautowrite foldnestmax=20 nopreserveindent tagstack noautowriteall formatexpr= previewheight=12 term=teraterm background=light formatoptions=tcq nopreviewwindow notermbidi nobackup formatprg= printdevice= termencoding= backupcopy=auto fsync printencoding= noterse backupext=~ nogdefault printfont=courier textauto backupskip=/tmp/* helpheight=20 printmbcharset= notextmode nobinary helplang=ja printmbfont= textwidth=0 nobomb nohidden printoptions= thesaurus= bufhidden= history=50 prompt notildeop buflisted nohkmap pumheight=0 timeout buftype= nohkmapp quoteescape=\ timeoutlen=1000 -- 継続 --~/.vimrc の例
" VIM 用オプション設定例 set nu ts=4 sw=4 ic |