Linux:壓縮命令

壓縮命令:
  *.Z             compress   程式壓縮的檔案;  
  *.bz2         bzip2   程式壓縮的檔案;  
  *.gz           gzip   程式壓縮的檔案;  
  *.tar         tar   程式打包的資料,並沒有壓縮過;  
  *.tar.gz   tar   程式打包的檔案,其中並且經過   gzip   的壓縮
compress   filename     壓縮文件     加[-d]解壓     uncompress
gzip   filename       壓縮     加[-d]解壓     zcat   123.gz   查看壓縮文件內容
bzip2   -z   filename     壓縮     加[-d]解壓       bzcat   filename.bz2     查看壓縮文件內容
tar   -cvf   /home/123.tar   /etc     打包,不壓縮
tar   -xvf   123.tar       解開包
tar   -zxvf   /home/123.tar.gz     以gzip解壓
tar   -jxvf   /home/123.tar.bz2     以bzip2解壓
tar   -ztvf   /tmp/etc.tar.gz       查看tar內容
cpio   -covB     >   [file ¦device]       份份
cpio   -icduv   <   [file ¦device]       還原
 
vi一般用法
一般模式                             編輯模式                                     指令模式
h   左                               a,i,r,o,A,I,R,O                           :w   保存
j   下                                 進入編輯模式                                 :w!   強制保存
k   上                                 dd   刪除光標當前行                       :q!   不保存離開
l   右                                 ndd   刪除n行                                   :wq!   保存後離開
0   移動到行首                 yy   複製當前行                                 :e!   還原原始檔
$   移動到行尾                 nyy   複製n行                                     :w   filename   另存爲
H   屏幕最上                     p,P   粘貼                                           :set   nu   設置行號
M   屏幕中央                     u     撤消                                             :set   nonu   取消行號
L   屏幕最下                     [Ctrl]+r   重做上一個動作               ZZ   保存離開
G   檔案最後一行             [ctrl]+z   暫停退出                         :set   nohlsearch       永久地關閉高亮顯示
/work   向下搜索                                                                       :sp   同時打開兩個文檔  
?work   向上搜索                                                                       [Ctrl]+w   兩個文檔設換
gg   移動到檔案第一行                                                             :nohlsearch         暫時關閉高亮顯示
 
認識SHELL
alias         顯示當前所有的命令別名             alias   lm= "ls   -al "       命令別名         unalias   lm   取消命令別名
type             類似which
exprot         設置或顯示環境變量
exprot   PATH= "$PATH ":/sbin     添加/sbin入PATH路徑
echo   $PATH         顯示PATH路徑
bash             進入子程序
name=yang           設定變量
unset   name         取消變量
echo   $name         顯示變量的內容
myname= "$name   its   me "       &       myname= &apos;$name   its   me &apos;           單引號時$name失去變量內容
ciw=/etc/sysconfig/network-scripts/           設置路徑
env             列出所有環境變量
echo   $RANDOM         顯示隨意產生的數
set             設置SHELL
PS1= &apos;[/u@/h   /w   /A   #/#]/$   &apos;           提示字元的設定
      [root@linux   ~]#   read   [-pt]   variable           -----------讀取鍵盤輸入的變量
      參數:
      -p     :後面可以接提示字元!
      -t     :後面可以接等待的『秒數!』
declare         聲明   shell   變量
ulimit   -a       顯示所有限制資料
  ls   /tmp/yang   &&   echo   "exist "   ¦ ¦   echo   "not   exist "
  意思是說,當   ls   /tmp/yang   執行後,若正確,就執行echo   "exist "   ,若有問題,就執行echo   "not   exist "  
  echo   $PATH   ¦   cut   -d   &apos;: &apos;   -f   5               以:爲分隔符,讀取第5段內容
  export   ¦   cut   -c   10-20             讀取第10到20個字節的內容
  last   ¦   grep   &apos;root &apos;         搜索有root的一行,加[-v]反向搜索
  cat   /etc/passwd   ¦   sort         排序顯示
  cat   /etc/passwd   ¦   wc             顯示『行、字數、字節數』
正規表示法
[root@test   root]#   grep   [-acinv]   &apos;搜尋字串 &apos;   filename
              參數說明:
              -a   :將   binary   檔案以   text   檔案的方式搜尋資料
              -c   :計算找到   &apos;搜尋字串 &apos;   的次數
              -i   :忽略大小寫的不同,所以大小寫視為相同
              -n   :順便輸出行號
              -v   :反向選擇,亦即顯示出沒有   &apos;搜尋字串 &apos;   內容的那一行!
  grep   -n   &apos;the &apos;   123.txt           搜索the字符   -----------搜尋特定字串              
  grep   -n   &apos;t[ea]st &apos;   123.txt         搜索test或taste兩個字符---------利用   []   來搜尋集合字元
  grep   -n   &apos;[^g]oo &apos;   123.txt           搜索前面不爲g的oo-----------向選擇   [^]  
  grep   -n   &apos;[0-9] &apos;   123.txt     搜索有0-9的數字
  grep   -n   &apos;^the &apos;   123.txt   搜索以the爲行首-----------行首搜索^
  grep   -n   &apos;^[^a-zA-Z] &apos;   123.txt     搜索不以英文字母開頭
  grep   -n   &apos;[a-z]$ &apos;   123.txt         搜索以a-z結尾的行----------   行尾搜索$
  grep   -n   &apos;g..d &apos;   123.txt           搜索開頭g結尾d字符----------任意一個字元   .  
  grep   -n   &apos;ooo* &apos;   123.txt           搜索至少有兩個oo的字符---------重複字元   *
sed         文本流編輯器         利用腳本命令來處理文本文件
awd         模式掃描和處理語言
  nl   123.txt   ¦   sed   &apos;2,5d &apos;       刪除第二到第五行的內容
diff           比較文件的差異
cmp             比較兩個文件是否有差異
patch         修補文件
pr               要打印的文件格式化 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章