使用tar打包并使用gzip壓縮的shell腳本應用實驗

博客目的:

練習find,gzip,tar,grep,vim等命令的使用以及shell腳本的初步使用

命令行模式下:

1、find出/目錄下100M以上的文件并且查看
[root@rookie ~]# find / -size +100M | xargs ls -lh 
-r--------. 1 root root 128T 48 16:02 /proc/kcore
-rw-------. 1 root root 128M 48 15:42 /sys/devices/pci0000:00/0000:00:0f.0/resource1
-rw-------. 1 root root 128M 48 15:42 /sys/devices/pci0000:00/0000:00:0f.0/resource1_wc
-rw-r--r--. 1 root root 102M 322 16:36 /usr/lib/locale/locale-archive 
2、將/usr/lib/locale/locale-archive文件拷貝至/tmp目錄下并且創建test文件
cp /usr/lib/locale/locale-archive /tmp/test 
3、查看test文件
[root@rookie ~]# ll -h /tmp/test 總用量 102M
-rw-r--r--. 1 root root 102M 48 16:07 locale-archive 
4、將test下的locale-archive文件打包并壓縮成.tar.g并查看
[root@rookie test]# tar -zcf locale-archive.tar.gz locale-archive  
[root@rookie test]# ll -h 總用量 124M
-rw-r--r--. 1 root root 102M 48 16:07 locale-archive
-rw-r--r--. 1 root root 23M 48 16:13 locale-archive.tar.gz

編寫shell腳本: 先使用vim編輯一個名為shelltest.sh的文件

#!/bin/bash 
# 
#Filename:shelltest 
#Description:tar,gzip,shell,vim,test 
#Author:no 
#Note:no #Date:`date +%y-%m-%d-%H-%M` 
# cd /tmp
mkdir test cd -
TESTFILE=find / -size +100M -size -200M
cp $TESTFILE /tmp/test cd /tmp/test 
tar zcvf tartest.tar.gz -T /tmp/test 
:wq
bash shelltest.sh

原創文章,作者:半斤八兩,如若轉載,請注明出處:http://www.www58058.com/72915

(2)
半斤八兩半斤八兩
上一篇 2017-04-09
下一篇 2017-04-09

相關推薦

  • 文件共享服務之SAMBA

    文件共享服務之SAMBA 文件共享服務之SAMBA 一、samba出現的意義 二、samba協議描述 三、samba為客戶端的實現 四、samba為服務端的實現 五、使用圖形界面配置SAMBA 一、samba出現的意義 首先nfs實現系統文件掛載linux與linux之間,linux到windows之間實現的并不是那么理想 FTP可以實現linux和wind…

    Linux干貨 2016-04-19
  • 沉舟側畔千帆進,枯木頭前萬樹春

    N21第五周博客作業 1、  顯示/boot/grub/grub.conf中以至少一個空白字符開頭的行; ~]#  grep -E "^[[:space:]]+" //boot/grub/grub.conf root (hd0,0) kernel /vmlin…

    Linux干貨 2016-07-29
  • 馬哥教育網絡班21期+第2周課程練習

    一、Linux文件管理類命令匯總 1、文件的復制命令:cp 復制命令:cp     cp [OPTION]… [-T] SOURCE DEST     cp [OPTION]… SOURCE… DI…

    Linux干貨 2016-07-29
  • 軟件安裝包的管理

    rpm安裝包的管理 rpm的數據庫( 公共) :/var/lib/rpm 程序包名稱及版本 依賴關系 功能說明 包安裝后生成的各文件路徑及校驗碼信息 安裝 rpm:{-i} -v:顯示詳細信息 -h:以#顯示程序包管理執行進度 rpm -ivh PACKAGE_FILE … [install-options] –test :測試安裝,但不真正執行安裝過程 –…

    Linux干貨 2017-04-23
  • I/O重定向及管道

    一、I/O重定向     程序=指定+數據     讀取數據:input     輸出數據:output     打開的文件都有一個fd:文件描述符     l…

    Linux干貨 2016-08-02
  • grep文本查找和正則表達式

    一、grep grep: (Global search REgular expression and Print outthe line)全局查找正則表達式并且打印結果行。不會對輸入的文本進行修改。 Unix的grep家族包括grep、egrep和fgrep,egrep是grep的擴展,支持更多的正則元字符; fgrep就是fixed grep或f…

    Linux干貨 2016-08-07

評論列表(1條)

  • renjin
    renjin 2017-04-12 11:37

    排版挺好的,內容有些少,可以把學過的內容詳細的總結一下

欧美性久久久久