新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
Linux中冷門但非常實用的六個命令
Linux中命令非常多,有一些非常實用的命令但是被大家所忽略,本篇文章重點為大家整理的Linux系統(tǒng)中非常使用的六個命令,有需要的小伙伴可以參考一下。

1. bc
這個Linux命令用于精度比較高的數(shù)學運算。如:開平方根等。下面利用bc命令寫個腳本(文件名:sqrt)
#!/bin/bash
if [ $
then
echo 'Usage: sqrt number'
exit 1
else
echo -e "sqrt($1)\nquit\n" | bc -q -i
fi
接著,可使用這個腳本進行平方根運算:
[hchen@RHELSVR5]$ ./sqrt 36
6
[hchen@RHELSVR5]$ ./sqrt 2.0000
1.4142
[hchen@RHELSVR5]$ ./sqrt 10.0000
3.1622
2. split
如果你的文件很大,卻接到命令要把它分割成小文件,那么這個命令就派上用場了。
[hchen@RHELSVR5 applebak]# ls -l largefile.tar.gz
-rw-r--r-- 1 hchen hchen 436774774 04-17 02:00 largefile.tar.gz
[hchen@RHELSVR5 applebak]# split -b 50m largefile.tar.gz LF_
[hchen@RHELSVR5]# ls -l LF_*
-rw-r--r-- 1 hchen hchen 52428800 05-10 18:34 LF_aa
-rw-r--r-- 1 hchen hchen 52428800 05-10 18:34 LF_ab
-rw-r--r-- 1 hchen hchen 52428800 05-10 18:34 LF_ac
-rw-r--r-- 1 hchen hchen 52428800 05-10 18:34 LF_ad
-rw-r--r-- 1 hchen hchen 52428800 05-10 18:34 LF_ae
-rw-r--r-- 1 hchen hchen 52428800 05-10 18:35 LF_af
-rw-r--r-- 1 hchen hchen 52428800 05-10 18:35 LF_ag
-rw-r--r-- 1 hchen hchen 52428800 05-10 18:35 LF_ah
-rw-r--r-- 1 hchen hchen 17344374 05-10 18:35 LF_ai
反而來,合并也只需要簡單的合并就行,如:
[hchen@RHELSVR5]# cat LF_* >largefile.tar.gz
3. pgrep
pgrep名字前有個p,可以猜想它可能和grep有關(guān),確實這是進程相關(guān)的grep命令。不過,這個命令主要是用來列舉進程ID的。如:
$ pgrep -u hchen
22441
22444
這個命令相當于:
ps -ef | egrep '^hchen' | awk '{print $2}'
4. nl
nl命令其它和cat命令很像,只不過它會打上行號。如下所示:
[hchen@RHELSVR5 include]# nl stdio.h | head -n 10
1 /* Define ISO C stdio on top of C++ iostreams.
2 Copyright (C) 1991,1994-2004,2005,2006 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8 The GNU C Library is distributed in the hope that it will be useful,
5. ldd
這個命令,用來可執(zhí)行文件所使用了動態(tài)鏈接庫。如:
[hchen@RHELSVR5 ~]# ldd /usr/bin/java
linux-gate.so.1 => (0x00cd9000)
libgij.so.7rh => /usr/lib/libgij.so.7rh (0x00ed3000)
libgcj.so.7rh => /usr/lib/libgcj.so.7rh (0x00ed6000)
libpthread.so.0 => /lib/i686/nosegneg/libpthread.so.0 (0x00110000)
librt.so.1 => /lib/i686/nosegneg/librt.so.1 (0x009c8000)
libdl.so.2 => /lib/libdl.so.2 (0x008b5000)
libz.so.1 => /usr/lib/libz.so.1 (0x00bee000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00aa7000)
libc.so.6 => /lib/i686/nosegneg/libc.so.6 (0x0022f000)
libm.so.6 => /lib/i686/nosegneg/libm.so.6 (0x00127000)
/lib/ld-linux.so.2 (0x00214000)
6. col
這個命令,能將man文件轉(zhuǎn)成純文本文件。如下示例:
# PAGER=cat
# man less | col -b > less.txt
名稱欄目:Linux中冷門但非常實用的六個命令
本文網(wǎng)址:http://fisionsoft.com.cn/article/coopjoc.html


咨詢
建站咨詢
