tar命令(轉)
tar命令(轉)[@more@]作者: Roast Duck [文章出自: ]也談tar命令 作者:dadaball 發表於:2003-09-24 21:28:02怎樣使用tar命令打包(備份)檔案?A:The syntax of tar is:tar [options][files]The options used most often with tar are as follows:c Creates a new backup,overwriting any files already on the backup destination.x Extracts files from backup media.t Lists the contents of backup media.v Displays the name of each file being processed.f Creates backups on a specified device.u Adds files to the backup if they are not already there,or if they have been modified since they were last written on the backup.步驟:1)估算打包檔案的大小,確定使用檔案媒體(archive media)的空間,用命令du -s例如:$ lfa.out* fork.c mbox time.catoi.c int.c memcpy.c vi$ du -s296 .$該例顯示的296代表the total number of 512-byte blocks,計算:512*296/1024=148kilobytes.2)製作備份,用命令tar cvf /dev/fd0135ds18 .(將該目錄下的所有內容備份到1.44英寸軟盤中where c causes a new backup to be created,v causes each file to be displayed as the backing up takes place,and f causes the subsequent argument--/dev/fd0135ds18 to be the destination of the backup.)注:平時硬碟上的備份,我們一般用命令tar cvf filename.tar .例如:$ tar cvf wuyd.tar .a ./.profile 2 tape blocksa ./.lastlogin 0 tape blocksa ./mbox 10 tape blocksa ./fork.c 2 tape blocksa ./memcpy.c 1 tape blocksa ./.sh_history 3 tape blocksa ./a.out 91 tape blocksa ./time.c 1 tape blocksa ./vi 169 tape blocksa ./int.c 1 tape blocksa ./atoi.c 1 tape blockstar: same as archive file: ./wuyd.tara ./.scoadmin.pref 1 tape blocks$ lfa.out* fork.c mbox time.c wuyd.taratoi.c int.c memcpy.c vi我們還可以用命令tar cvf /dev/fd0135ds18 ./filename將該目錄下的名為filename的檔案備份到archive media中怎樣列出tar文件的內容?A:tar tvf /dev/fd0135ds18tar tvf filename.tar例如:$ tar tvf wuyd.tartar: blocksize = 20rw-------203/50 896 Sep 17 15:07 2003 ./.profiler--------203/21 0 Sep 24 19:49 2003 ./.lastloginrw-------203/50 4720 Sep 21 11:17 2003 ./mboxrw-r--r--203/50 583 Sep 17 15:27 2003 ./fork.crw-r--r--203/50 218 Sep 17 20:22 2003 ./memcpy.crw-------203/50 1474 Sep 24 20:26 2003 ./.sh_historyrwxr-xr-x203/50 46224 Sep 22 21:00 2003 ./a.outrw-r--r--203/50 341 Sep 19 09:02 2003 ./time.crw-r--r--203/50 86283 Sep 21 09:14 2003 ./virw-r--r--203/50 93 Sep 21 10:53 2003 ./int.crw-r--r--203/50 144 Sep 22 21:00 2003 ./atoi.crw-r--r-- 0/3 41 Sep 23 20:34 2003 ./.scoadmin.pref$怎樣從tar文件中匯出檔案?A:tar xvf /dev/fd0135ds18tar xvf filename.tar例如:$ mkdir uu;cp wuyd.tar ./uu$ lfa.out* fork.c mbox time.c viatoi.c int.c memcpy.c uu/ wuyd.tar$ cd uu$ tar xvf wuyd.tartar: blocksize = 20x ./.profile, 896 bytes, 2 tape blocksx ./.lastlogin, 0 bytes, 0 tape blocksx ./mbox, 4720 bytes, 10 tape blocksx ./fork.c, 583 bytes, 2 tape blocksx ./memcpy.c, 218 bytes, 1 tape blocksx ./.sh_history, 1474 bytes, 3 tape blocksx ./a.out, 46224 bytes, 91 tape blocksx ./time.c, 341 bytes, 1 tape blocksx ./vi, 86283 bytes, 169 tape blocksx ./int.c, 93 bytes, 1 tape blocksx ./atoi.c, 144 bytes, 1 tape blocksx ./.scoadmin.pref, 41 bytes, 1 tape blocks$我們可用命令tar xvf /dev/fd0135ds18 ./filename匯出archive media中的單個檔案例如:$ lfwuyd.tar$ tar xvf wuyd.tar ./time.ctar: blocksize = 20x ./time.c, 341 bytes, 1 tape blocks$ lftime.c wuyd.tar$怎樣使用tar命令提供的簡寫形式?A:$ more /etc/default/tar# @(#) def135.src 25.2 94/07/25## Copyright (C) 1987-1994 The Santa Cruz Operation, Inc.# All Rights Reserved.# The information in this file is provided for the exclusive use of# the licensees of The Santa Cruz Operation, Inc. Such users have the# right to use, modify, and incorporate this code into other products# for purposes authorized by the license agreement provided they include# this notice and the associated copyright notice with any such product.# The information in this file is provided "AS IS" without warranty.## default/tar - archive devices: tar(C)## device block size tape#archive0=/dev/rfd048ds9 18 360 narchive1=/dev/rfd148ds9 18 360 narchive2=/dev/rfd096ds15 10 1200 narchive3=/dev/rfd196ds15 10 1200 n# archive4=/dev/rfd096ds9 18 720 narchive4=/dev/rfd0135ds9 18 720 narchive5=/dev/rfd1135ds9 18 720 n# archive5=/dev/rfd196ds9 18 720 narchive6=/dev/rfd0135ds18 18 1440 narchive7=/dev/rfd1135ds18 18 1440 narchive8=/dev/rct0 20 0 yarchive9=/dev/rctmini 20 0 yarchive10=/dev/rdsk/fp03d 18 720 narchive11=/dev/rdsk/fp03h 18 1440 narchive12=/dev/rdsk/fp03v21 10 20330 n## The default device in the absence of a numeric or "-f device" argumentarchive=/dev/rfd0135ds18 18 1440 n$從上面可以看出4代表/dev/rfd0135ds9裝置,而預設的裝置是/dev/rfd0135ds18,所以tar xvf /dev/rfd0135ds9 ./filename可以簡寫為tar xv4 ./filename,而tar cvf /dev/fd0135ds18 .可以簡寫為tar cv
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8225414/viewspace-940535/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Linux命令篇 - tar 命令Linux
- Linux 命令之 tarLinux
- mac 的tar命令--exclude和linux的tar命令--exclude的區別MacLinux
- 壓縮命令tar詳解
- tar命令引數詳解
- tar命令基本、進階使用指北
- 掌握 tar 命令讓你秒變大牛
- Linux 中 17 個 tar 命令實用示例Linux
- tar.gz壓縮命令使用方法
- Linux tar打包命令詳解,附實戰案例!Linux
- linux中常見的打包壓縮命令——tar、jarLinuxJAR
- [轉帖]Linux tar壓縮命令 排除某個目錄 && 排除某種格式字尾檔案Linux
- Linux下的tar壓縮解壓縮命令詳解Linux
- 學習Linux tar 命令:最簡單也最困難Linux
- tar命令打包技巧有什麼?linux運維命令學習入門過程Linux運維
- 在Linux中,如何使用tar命令建立和恢復備份?Linux
- Linux命令:XZ解壓tar.xz字尾的壓縮包Linux
- 在Linux中,如何進行備份或歸檔檔案(tar 命令)?Linux
- Linux下tar命令的各種引數選項和他們的作用整理Linux
- 如何使用Tar命令在Linux系統中解壓各種檔案格式Linux
- tar命令打包指定目錄及其檔案,而不包括其上級目錄
- tar解壓報錯——Not found in archive tar: Exiting with failure status due to previous errorsHiveAIError
- tar解包時報錯
- Linux轉包命令Linux
- [轉] composer – 文件 – 命令列命令列
- SVN命令詳解【轉】
- linux的test命令(轉)Linux
- vi命令詳解(轉)
- [轉帖]剖析free命令
- tar方式安裝資料庫資料庫
- (轉)Git常用終端命令Git
- 教你玩轉Linux—yum 命令Linux
- 命令模式 :Command(轉自LoveCherry)模式
- (轉)Redis常用命令Redis
- powermt 命令簡介(轉載)
- CAD如何使用旋轉命令
- tar打包且排除某個檔案
- mysql5.7tar包的安裝MySql
- .tar.xz 的解壓方式 centosCentOS