常用命令-2

SORT

預設按字符嘅編碼排序,唔係數值。

sort - sort lines of text files

按逆序排列

sort -r file

按數值排序

sort -n file

按月份排序

月份格式:JanFebMar

sort -M file

指定列

預設按(連續嘅)空格或者制表符分隔。

sort -k 1 file

指定分隔符同列

-k 下標由 1 開始,第 3 列係用戶 ID。

sort -t ':' -k 3 -n /etc/passwd

忽略大小寫

sort -f file

結果去重

sort -u file

ALIAS

sort - sort lines of text files

睇可能嘅別名

alias -p

TYPE

外/內部命令

可以睇命令係咪內部命令,內部命令同 Shell 編譯成一體,同外部命令唔同,唔使子進程執行。

type cd
cd is a shell builtin

type ps
ps is hashed (/usr/bin/ps)

睇所有實現

type -a echo
echo is a shell builtin
echo is /usr/bin/echo
echo is /bin/echo

睇命令嘅別名

type ll
ll is aliased to `ls -alF'

type -a ls
ls is aliased to `ls --color=auto'
ls is /usr/bin/ls
ls is /bin/ls
readlink - print resolved symbolic links or canonical file names

睇最後嘅鏈接

唔使一個一個睇。

readlink -f /bin/vim
/usr/bin/vim.basic