tar.texi 392 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486
  1. \input texinfo @c -*-texinfo-*-
  2. @comment %**start of header
  3. @setfilename tar.info
  4. @include version.texi
  5. @settitle GNU tar @value{VERSION}
  6. @setchapternewpage odd
  7. @finalout
  8. @smallbook
  9. @c %**end of header
  10. @include rendition.texi
  11. @include value.texi
  12. @c Put everything in one index (arbitrarily chosen to be the concept index).
  13. @syncodeindex fn cp
  14. @syncodeindex ky cp
  15. @syncodeindex pg cp
  16. @syncodeindex vr cp
  17. @defindex op
  18. @copying
  19. This manual is for @acronym{GNU} @command{tar} (version
  20. @value{VERSION}, @value{UPDATED}), which creates and extracts files
  21. from archives.
  22. Copyright @copyright{} 1992, 1994, 1995, 1996, 1997, 1999, 2000, 2001,
  23. 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
  24. @quotation
  25. Permission is granted to copy, distribute and/or modify this document
  26. under the terms of the GNU Free Documentation License, Version 1.1 or
  27. any later version published by the Free Software Foundation; with no
  28. Invariant Sections, with the Front-Cover Texts being ``A GNU Manual,''
  29. and with the Back-Cover Texts as in (a) below. A copy of the license
  30. is included in the section entitled "GNU Free Documentation License".
  31. (a) The FSF's Back-Cover Text is: ``You are free to copy and modify
  32. this GNU Manual. Buying copies from GNU Press supports the FSF in
  33. developing GNU and promoting software freedom.''
  34. @end quotation
  35. @end copying
  36. @dircategory Archiving
  37. @direntry
  38. * Tar: (tar). Making tape (or disk) archives.
  39. @end direntry
  40. @dircategory Individual utilities
  41. @direntry
  42. * tar: (tar)tar invocation. Invoking @GNUTAR{}.
  43. @end direntry
  44. @shorttitlepage @acronym{GNU} @command{tar}
  45. @titlepage
  46. @title @acronym{GNU} tar: an archiver tool
  47. @subtitle @value{RENDITION} @value{VERSION}, @value{UPDATED}
  48. @author John Gilmore, Jay Fenlason et al.
  49. @page
  50. @vskip 0pt plus 1filll
  51. @insertcopying
  52. @end titlepage
  53. @ifnottex
  54. @node Top
  55. @top @acronym{GNU} tar: an archiver tool
  56. @insertcopying
  57. @cindex file archival
  58. @cindex archiving files
  59. The first part of this master menu lists the major nodes in this Info
  60. document. The rest of the menu lists all the lower level nodes.
  61. @end ifnottex
  62. @c The master menu, created with texinfo-master-menu, goes here.
  63. @c (However, getdate.texi's menu is interpolated by hand.)
  64. @menu
  65. * Introduction::
  66. * Tutorial::
  67. * tar invocation::
  68. * operations::
  69. * Backups::
  70. * Choosing::
  71. * Date input formats::
  72. * Formats::
  73. * Media::
  74. Appendices
  75. * Changes::
  76. * Configuring Help Summary::
  77. * Genfile::
  78. * Snapshot Files::
  79. * Dumpdir::
  80. * Free Software Needs Free Documentation::
  81. * Copying This Manual::
  82. * Index of Command Line Options::
  83. * Index::
  84. @detailmenu
  85. --- The Detailed Node Listing ---
  86. Introduction
  87. * Book Contents:: What this Book Contains
  88. * Definitions:: Some Definitions
  89. * What tar Does:: What @command{tar} Does
  90. * Naming tar Archives:: How @command{tar} Archives are Named
  91. * Authors:: @GNUTAR{} Authors
  92. * Reports:: Reporting bugs or suggestions
  93. Tutorial Introduction to @command{tar}
  94. * assumptions::
  95. * stylistic conventions::
  96. * basic tar options:: Basic @command{tar} Operations and Options
  97. * frequent operations::
  98. * Two Frequent Options::
  99. * create:: How to Create Archives
  100. * list:: How to List Archives
  101. * extract:: How to Extract Members from an Archive
  102. * going further::
  103. Two Frequently Used Options
  104. * file tutorial::
  105. * verbose tutorial::
  106. * help tutorial::
  107. How to Create Archives
  108. * prepare for examples::
  109. * Creating the archive::
  110. * create verbose::
  111. * short create::
  112. * create dir::
  113. How to List Archives
  114. * list dir::
  115. How to Extract Members from an Archive
  116. * extracting archives::
  117. * extracting files::
  118. * extract dir::
  119. * failing commands::
  120. Invoking @GNUTAR{}
  121. * Synopsis::
  122. * using tar options::
  123. * Styles::
  124. * All Options::
  125. * help::
  126. * defaults::
  127. * verbose::
  128. * interactive::
  129. The Three Option Styles
  130. * Mnemonic Options:: Mnemonic Option Style
  131. * Short Options:: Short Option Style
  132. * Old Options:: Old Option Style
  133. * Mixing:: Mixing Option Styles
  134. All @command{tar} Options
  135. * Operation Summary::
  136. * Option Summary::
  137. * Short Option Summary::
  138. @GNUTAR{} Operations
  139. * Basic tar::
  140. * Advanced tar::
  141. * create options::
  142. * extract options::
  143. * backup::
  144. * Applications::
  145. * looking ahead::
  146. Advanced @GNUTAR{} Operations
  147. * Operations::
  148. * append::
  149. * update::
  150. * concatenate::
  151. * delete::
  152. * compare::
  153. How to Add Files to Existing Archives: @option{--append}
  154. * appending files:: Appending Files to an Archive
  155. * multiple::
  156. Updating an Archive
  157. * how to update::
  158. Options Used by @option{--create}
  159. * Ignore Failed Read::
  160. Options Used by @option{--extract}
  161. * Reading:: Options to Help Read Archives
  162. * Writing:: Changing How @command{tar} Writes Files
  163. * Scarce:: Coping with Scarce Resources
  164. Options to Help Read Archives
  165. * read full records::
  166. * Ignore Zeros::
  167. Changing How @command{tar} Writes Files
  168. * Dealing with Old Files::
  169. * Overwrite Old Files::
  170. * Keep Old Files::
  171. * Keep Newer Files::
  172. * Unlink First::
  173. * Recursive Unlink::
  174. * Data Modification Times::
  175. * Setting Access Permissions::
  176. * Writing to Standard Output::
  177. * remove files::
  178. Coping with Scarce Resources
  179. * Starting File::
  180. * Same Order::
  181. Performing Backups and Restoring Files
  182. * Full Dumps:: Using @command{tar} to Perform Full Dumps
  183. * Incremental Dumps:: Using @command{tar} to Perform Incremental Dumps
  184. * Backup Levels:: Levels of Backups
  185. * Backup Parameters:: Setting Parameters for Backups and Restoration
  186. * Scripted Backups:: Using the Backup Scripts
  187. * Scripted Restoration:: Using the Restore Script
  188. Setting Parameters for Backups and Restoration
  189. * General-Purpose Variables::
  190. * Magnetic Tape Control::
  191. * User Hooks::
  192. * backup-specs example:: An Example Text of @file{Backup-specs}
  193. Choosing Files and Names for @command{tar}
  194. * file:: Choosing the Archive's Name
  195. * Selecting Archive Members::
  196. * files:: Reading Names from a File
  197. * exclude:: Excluding Some Files
  198. * wildcards:: Wildcards Patterns and Matching
  199. * quoting styles:: Ways of Quoting Special Characters in Names
  200. * transform:: Modifying File and Member Names
  201. * after:: Operating Only on New Files
  202. * recurse:: Descending into Directories
  203. * one:: Crossing File System Boundaries
  204. Reading Names from a File
  205. * nul::
  206. Excluding Some Files
  207. * problems with exclude::
  208. Crossing File System Boundaries
  209. * directory:: Changing Directory
  210. * absolute:: Absolute File Names
  211. Date input formats
  212. * General date syntax:: Common rules.
  213. * Calendar date items:: 19 Dec 1994.
  214. * Time of day items:: 9:20pm.
  215. * Time zone items:: @sc{est}, @sc{pdt}, @sc{gmt}, ...
  216. * Day of week items:: Monday and others.
  217. * Relative items in date strings:: next tuesday, 2 years ago.
  218. * Pure numbers in date strings:: 19931219, 1440.
  219. * Seconds since the Epoch:: @@1078100502.
  220. * Authors of get_date:: Bellovin, Eggert, Salz, Berets, et al.
  221. Controlling the Archive Format
  222. * Portability:: Making @command{tar} Archives More Portable
  223. * Compression:: Using Less Space through Compression
  224. * Attributes:: Handling File Attributes
  225. * Standard:: The Standard Format
  226. * Extensions:: @acronym{GNU} Extensions to the Archive Format
  227. * cpio:: Comparison of @command{tar} and @command{cpio}
  228. Making @command{tar} Archives More Portable
  229. * Portable Names:: Portable Names
  230. * dereference:: Symbolic Links
  231. * old:: Old V7 Archives
  232. * posix:: @acronym{POSIX} archives
  233. * Checksumming:: Checksumming Problems
  234. * Large or Negative Values:: Large files, negative time stamps, etc.
  235. Using Less Space through Compression
  236. * gzip:: Creating and Reading Compressed Archives
  237. * sparse:: Archiving Sparse Files
  238. Tapes and Other Archive Media
  239. * Device:: Device selection and switching
  240. * Remote Tape Server::
  241. * Common Problems and Solutions::
  242. * Blocking:: Blocking
  243. * Many:: Many archives on one tape
  244. * Using Multiple Tapes:: Using Multiple Tapes
  245. * label:: Including a Label in the Archive
  246. * verify::
  247. * Write Protection::
  248. Blocking
  249. * Format Variations:: Format Variations
  250. * Blocking Factor:: The Blocking Factor of an Archive
  251. Many Archives on One Tape
  252. * Tape Positioning:: Tape Positions and Tape Marks
  253. * mt:: The @command{mt} Utility
  254. Using Multiple Tapes
  255. * Multi-Volume Archives:: Archives Longer than One Tape or Disk
  256. * Tape Files:: Tape Files
  257. * Tarcat:: Concatenate Volumes into a Single Archive
  258. GNU tar internals and development
  259. * Genfile::
  260. * Snapshot Files::
  261. * Dumpdir::
  262. Copying This Manual
  263. * Free Software Needs Free Documentation::
  264. * GNU Free Documentation License:: License for copying this manual
  265. @end detailmenu
  266. @end menu
  267. @node Introduction
  268. @chapter Introduction
  269. @GNUTAR{} creates
  270. and manipulates @dfn{archives} which are actually collections of
  271. many other files; the program provides users with an organized and
  272. systematic method for controlling a large amount of data.
  273. The name ``tar'' originally came from the phrase ``Tape ARchive'', but
  274. archives need not (and these days, typically do not) reside on tapes.
  275. @menu
  276. * Book Contents:: What this Book Contains
  277. * Definitions:: Some Definitions
  278. * What tar Does:: What @command{tar} Does
  279. * Naming tar Archives:: How @command{tar} Archives are Named
  280. * Authors:: @GNUTAR{} Authors
  281. * Reports:: Reporting bugs or suggestions
  282. @end menu
  283. @node Book Contents
  284. @section What this Book Contains
  285. The first part of this chapter introduces you to various terms that will
  286. recur throughout the book. It also tells you who has worked on @GNUTAR{}
  287. and its documentation, and where you should send bug reports
  288. or comments.
  289. The second chapter is a tutorial (@pxref{Tutorial}) which provides a
  290. gentle introduction for people who are new to using @command{tar}. It is
  291. meant to be self contained, not requiring any reading from subsequent
  292. chapters to make sense. It moves from topic to topic in a logical,
  293. progressive order, building on information already explained.
  294. Although the tutorial is paced and structured to allow beginners to
  295. learn how to use @command{tar}, it is not intended solely for beginners.
  296. The tutorial explains how to use the three most frequently used
  297. operations (@samp{create}, @samp{list}, and @samp{extract}) as well as
  298. two frequently used options (@samp{file} and @samp{verbose}). The other
  299. chapters do not refer to the tutorial frequently; however, if a section
  300. discusses something which is a complex variant of a basic concept, there
  301. may be a cross reference to that basic concept. (The entire book,
  302. including the tutorial, assumes that the reader understands some basic
  303. concepts of using a Unix-type operating system; @pxref{Tutorial}.)
  304. The third chapter presents the remaining five operations, and
  305. information about using @command{tar} options and option syntax.
  306. @FIXME{this sounds more like a @acronym{GNU} Project Manuals Concept [tm] more
  307. than the reality. should think about whether this makes sense to say
  308. here, or not.} The other chapters are meant to be used as a
  309. reference. Each chapter presents everything that needs to be said
  310. about a specific topic.
  311. One of the chapters (@pxref{Date input formats}) exists in its
  312. entirety in other @acronym{GNU} manuals, and is mostly self-contained.
  313. In addition, one section of this manual (@pxref{Standard}) contains a
  314. big quote which is taken directly from @command{tar} sources.
  315. In general, we give both long and short (abbreviated) option names
  316. at least once in each section where the relevant option is covered, so
  317. that novice readers will become familiar with both styles. (A few
  318. options have no short versions, and the relevant sections will
  319. indicate this.)
  320. @node Definitions
  321. @section Some Definitions
  322. @cindex archive
  323. @cindex tar archive
  324. The @command{tar} program is used to create and manipulate @command{tar}
  325. archives. An @dfn{archive} is a single file which contains the contents
  326. of many files, while still identifying the names of the files, their
  327. owner(s), and so forth. (In addition, archives record access
  328. permissions, user and group, size in bytes, and data modification time.
  329. Some archives also record the file names in each archived directory, as
  330. well as other file and directory information.) You can use @command{tar}
  331. to @dfn{create} a new archive in a specified directory.
  332. @cindex member
  333. @cindex archive member
  334. @cindex file name
  335. @cindex member name
  336. The files inside an archive are called @dfn{members}. Within this
  337. manual, we use the term @dfn{file} to refer only to files accessible in
  338. the normal ways (by @command{ls}, @command{cat}, and so forth), and the term
  339. @dfn{member} to refer only to the members of an archive. Similarly, a
  340. @dfn{file name} is the name of a file, as it resides in the file system,
  341. and a @dfn{member name} is the name of an archive member within the
  342. archive.
  343. @cindex extraction
  344. @cindex unpacking
  345. The term @dfn{extraction} refers to the process of copying an archive
  346. member (or multiple members) into a file in the file system. Extracting
  347. all the members of an archive is often called @dfn{extracting the
  348. archive}. The term @dfn{unpack} can also be used to refer to the
  349. extraction of many or all the members of an archive. Extracting an
  350. archive does not destroy the archive's structure, just as creating an
  351. archive does not destroy the copies of the files that exist outside of
  352. the archive. You may also @dfn{list} the members in a given archive
  353. (this is often thought of as ``printing'' them to the standard output,
  354. or the command line), or @dfn{append} members to a pre-existing archive.
  355. All of these operations can be performed using @command{tar}.
  356. @node What tar Does
  357. @section What @command{tar} Does
  358. @cindex tar
  359. The @command{tar} program provides the ability to create @command{tar}
  360. archives, as well as various other kinds of manipulation. For example,
  361. you can use @command{tar} on previously created archives to extract files,
  362. to store additional files, or to update or list files which were already
  363. stored.
  364. Initially, @command{tar} archives were used to store files conveniently on
  365. magnetic tape. The name @command{tar} comes from this use; it stands for
  366. @code{t}ape @code{ar}chiver. Despite the utility's name, @command{tar} can
  367. direct its output to available devices, files, or other programs (using
  368. pipes). @command{tar} may even access remote devices or files (as archives).
  369. You can use @command{tar} archives in many ways. We want to stress a few
  370. of them: storage, backup, and transportation.
  371. @FIXME{the following table entries need a bit of work..}
  372. @table @asis
  373. @item Storage
  374. Often, @command{tar} archives are used to store related files for
  375. convenient file transfer over a network. For example, the
  376. @acronym{GNU} Project distributes its software bundled into
  377. @command{tar} archives, so that all the files relating to a particular
  378. program (or set of related programs) can be transferred as a single
  379. unit.
  380. A magnetic tape can store several files in sequence. However, the tape
  381. has no names for these files; it only knows their relative position on
  382. the tape. One way to store several files on one tape and retain their
  383. names is by creating a @command{tar} archive. Even when the basic transfer
  384. mechanism can keep track of names, as FTP can, the nuisance of handling
  385. multiple files, directories, and multiple links makes @command{tar}
  386. archives useful.
  387. Archive files are also used for long-term storage. You can think of
  388. this as transportation from the present into the future. (It is a
  389. science-fiction idiom that you can move through time as well as in
  390. space; the idea here is that @command{tar} can be used to move archives in
  391. all dimensions, even time!)
  392. @item Backup
  393. Because the archive created by @command{tar} is capable of preserving
  394. file information and directory structure, @command{tar} is commonly
  395. used for performing full and incremental backups of disks. A backup
  396. puts a collection of files (possibly pertaining to many users and
  397. projects) together on a disk or a tape. This guards against
  398. accidental destruction of the information in those files.
  399. @GNUTAR{} has special features that allow it to be
  400. used to make incremental and full dumps of all the files in a
  401. file system.
  402. @item Transportation
  403. You can create an archive on one system, transfer it to another system,
  404. and extract the contents there. This allows you to transport a group of
  405. files from one system to another.
  406. @end table
  407. @node Naming tar Archives
  408. @section How @command{tar} Archives are Named
  409. Conventionally, @command{tar} archives are given names ending with
  410. @samp{.tar}. This is not necessary for @command{tar} to operate properly,
  411. but this manual follows that convention in order to accustom readers to
  412. it and to make examples more clear.
  413. @cindex tar file
  414. @cindex entry
  415. @cindex tar entry
  416. Often, people refer to @command{tar} archives as ``@command{tar} files,'' and
  417. archive members as ``files'' or ``entries''. For people familiar with
  418. the operation of @command{tar}, this causes no difficulty. However, in
  419. this manual, we consistently refer to ``archives'' and ``archive
  420. members'' to make learning to use @command{tar} easier for novice users.
  421. @node Authors
  422. @section @GNUTAR{} Authors
  423. @GNUTAR{} was originally written by John Gilmore,
  424. and modified by many people. The @acronym{GNU} enhancements were
  425. written by Jay Fenlason, then Joy Kendall, and the whole package has
  426. been further maintained by Thomas Bushnell, n/BSG, Fran@,{c}ois
  427. Pinard, Paul Eggert, and finally Sergey Poznyakoff with the help of
  428. numerous and kind users.
  429. We wish to stress that @command{tar} is a collective work, and owes much to
  430. all those people who reported problems, offered solutions and other
  431. insights, or shared their thoughts and suggestions. An impressive, yet
  432. partial list of those contributors can be found in the @file{THANKS}
  433. file from the @GNUTAR{} distribution.
  434. @FIXME{i want all of these names mentioned, Absolutely. BUT, i'm not
  435. sure i want to spell out the history in this detail, at least not for
  436. the printed book. i'm just not sure it needs to be said this way.
  437. i'll think about it.}
  438. @FIXME{History is more important, and surely more interesting, than
  439. actual names. Quoting names without history would be meaningless. FP}
  440. Jay Fenlason put together a draft of a @GNUTAR{}
  441. manual, borrowing notes from the original man page from John Gilmore.
  442. This was withdrawn in version 1.11. Thomas Bushnell, n/BSG and Amy
  443. Gorin worked on a tutorial and manual for @GNUTAR{}.
  444. Fran@,{c}ois Pinard put version 1.11.8 of the manual together by
  445. taking information from all these sources and merging them. Melissa
  446. Weisshaus finally edited and redesigned the book to create version
  447. 1.12. The book for versions from 1.14 up to @value{VERSION} were edited
  448. by the current maintainer, Sergey Poznyakoff.
  449. For version 1.12, Daniel Hagerty contributed a great deal of technical
  450. consulting. In particular, he is the primary author of @ref{Backups}.
  451. In July, 2003 @GNUTAR{} was put on CVS at savannah.gnu.org
  452. (see @url{http://savannah.gnu.org/projects/tar}), and
  453. active development and maintenance work has started
  454. again. Currently @GNUTAR{} is being maintained by Paul Eggert, Sergey
  455. Poznyakoff and Jeff Bailey.
  456. Support for @acronym{POSIX} archives was added by Sergey Poznyakoff.
  457. @node Reports
  458. @section Reporting bugs or suggestions
  459. @cindex bug reports
  460. @cindex reporting bugs
  461. If you find problems or have suggestions about this program or manual,
  462. please report them to @file{bug-tar@@gnu.org}.
  463. When reporting a bug, please be sure to include as much detail as
  464. possible, in order to reproduce it. @FIXME{Be more specific, I'd
  465. like to make this node as detailed as 'Bug reporting' node in Emacs
  466. manual}.
  467. @node Tutorial
  468. @chapter Tutorial Introduction to @command{tar}
  469. This chapter guides you through some basic examples of three @command{tar}
  470. operations: @option{--create}, @option{--list}, and @option{--extract}. If
  471. you already know how to use some other version of @command{tar}, then you
  472. may not need to read this chapter. This chapter omits most complicated
  473. details about how @command{tar} works.
  474. @menu
  475. * assumptions::
  476. * stylistic conventions::
  477. * basic tar options:: Basic @command{tar} Operations and Options
  478. * frequent operations::
  479. * Two Frequent Options::
  480. * create:: How to Create Archives
  481. * list:: How to List Archives
  482. * extract:: How to Extract Members from an Archive
  483. * going further::
  484. @end menu
  485. @node assumptions
  486. @section Assumptions this Tutorial Makes
  487. This chapter is paced to allow beginners to learn about @command{tar}
  488. slowly. At the same time, we will try to cover all the basic aspects of
  489. these three operations. In order to accomplish both of these tasks, we
  490. have made certain assumptions about your knowledge before reading this
  491. manual, and the hardware you will be using:
  492. @itemize @bullet
  493. @item
  494. Before you start to work through this tutorial, you should understand
  495. what the terms ``archive'' and ``archive member'' mean
  496. (@pxref{Definitions}). In addition, you should understand something
  497. about how Unix-type operating systems work, and you should know how to
  498. use some basic utilities. For example, you should know how to create,
  499. list, copy, rename, edit, and delete files and directories; how to
  500. change between directories; and how to figure out where you are in the
  501. file system. You should have some basic understanding of directory
  502. structure and how files are named according to which directory they are
  503. in. You should understand concepts such as standard output and standard
  504. input, what various definitions of the term ``argument'' mean, and the
  505. differences between relative and absolute path names. @FIXME{and what
  506. else?}
  507. @item
  508. This manual assumes that you are working from your own home directory
  509. (unless we state otherwise). In this tutorial, you will create a
  510. directory to practice @command{tar} commands in. When we show path names,
  511. we will assume that those paths are relative to your home directory.
  512. For example, my home directory path is @file{/home/fsf/melissa}. All of
  513. my examples are in a subdirectory of the directory named by that path
  514. name; the subdirectory is called @file{practice}.
  515. @item
  516. In general, we show examples of archives which exist on (or can be
  517. written to, or worked with from) a directory on a hard disk. In most
  518. cases, you could write those archives to, or work with them on any other
  519. device, such as a tape drive. However, some of the later examples in
  520. the tutorial and next chapter will not work on tape drives.
  521. Additionally, working with tapes is much more complicated than working
  522. with hard disks. For these reasons, the tutorial does not cover working
  523. with tape drives. @xref{Media}, for complete information on using
  524. @command{tar} archives with tape drives.
  525. @FIXME{this is a cop out. need to add some simple tape drive info.}
  526. @end itemize
  527. @node stylistic conventions
  528. @section Stylistic Conventions
  529. In the examples, @samp{$} represents a typical shell prompt. It
  530. precedes lines you should type; to make this more clear, those lines are
  531. shown in @kbd{this font}, as opposed to lines which represent the
  532. computer's response; those lines are shown in @code{this font}, or
  533. sometimes @samp{like this}.
  534. @c When we have lines which are too long to be
  535. @c displayed in any other way, we will show them like this:
  536. @node basic tar options
  537. @section Basic @command{tar} Operations and Options
  538. @command{tar} can take a wide variety of arguments which specify and define
  539. the actions it will have on the particular set of files or the archive.
  540. The main types of arguments to @command{tar} fall into one of two classes:
  541. operations, and options.
  542. Some arguments fall into a class called @dfn{operations}; exactly one of
  543. these is both allowed and required for any instance of using @command{tar};
  544. you may @emph{not} specify more than one. People sometimes speak of
  545. @dfn{operating modes}. You are in a particular operating mode when you
  546. have specified the operation which specifies it; there are eight
  547. operations in total, and thus there are eight operating modes.
  548. The other arguments fall into the class known as @dfn{options}. You are
  549. not required to specify any options, and you are allowed to specify more
  550. than one at a time (depending on the way you are using @command{tar} at
  551. that time). Some options are used so frequently, and are so useful for
  552. helping you type commands more carefully that they are effectively
  553. ``required''. We will discuss them in this chapter.
  554. You can write most of the @command{tar} operations and options in any
  555. of three forms: long (mnemonic) form, short form, and old style. Some
  556. of the operations and options have no short or ``old'' forms; however,
  557. the operations and options which we will cover in this tutorial have
  558. corresponding abbreviations. @FIXME{make sure this is still the case,
  559. at the end}We will indicate those abbreviations appropriately to get
  560. you used to seeing them. (Note that the ``old style'' option forms
  561. exist in @GNUTAR{} for compatibility with Unix
  562. @command{tar}. In this book we present a full discussion of this way
  563. of writing options and operations (@pxref{Old Options}), and we discuss
  564. the other two styles of writing options (@xref{Mnemonic Options}, and
  565. @pxref{Short Options}).
  566. In the examples and in the text of this tutorial, we usually use the
  567. long forms of operations and options; but the ``short'' forms produce
  568. the same result and can make typing long @command{tar} commands easier.
  569. For example, instead of typing
  570. @smallexample
  571. @kbd{tar --create --verbose --file=afiles.tar apple angst aspic}
  572. @end smallexample
  573. @noindent
  574. you can type
  575. @smallexample
  576. @kbd{tar -c -v -f afiles.tar apple angst aspic}
  577. @end smallexample
  578. @noindent
  579. or even
  580. @smallexample
  581. @kbd{tar -cvf afiles.tar apple angst aspic}
  582. @end smallexample
  583. @noindent
  584. For more information on option syntax, see @ref{Advanced tar}. In
  585. discussions in the text, when we name an option by its long form, we
  586. also give the corresponding short option in parentheses.
  587. The term, ``option'', can be confusing at times, since ``operations''
  588. are often lumped in with the actual, @emph{optional} ``options'' in certain
  589. general class statements. For example, we just talked about ``short and
  590. long forms of options and operations''. However, experienced @command{tar}
  591. users often refer to these by shorthand terms such as, ``short and long
  592. options''. This term assumes that the ``operations'' are included, also.
  593. Context will help you determine which definition of ``options'' to use.
  594. Similarly, the term ``command'' can be confusing, as it is often used in
  595. two different ways. People sometimes refer to @command{tar} ``commands''.
  596. A @command{tar} @dfn{command} is the entire command line of user input
  597. which tells @command{tar} what to do --- including the operation, options,
  598. and any arguments (file names, pipes, other commands, etc). However,
  599. you will also sometimes hear the term ``the @command{tar} command''. When
  600. the word ``command'' is used specifically like this, a person is usually
  601. referring to the @command{tar} @emph{operation}, not the whole line.
  602. Again, use context to figure out which of the meanings the speaker
  603. intends.
  604. @node frequent operations
  605. @section The Three Most Frequently Used Operations
  606. Here are the three most frequently used operations (both short and long
  607. forms), as well as a brief description of their meanings. The rest of
  608. this chapter will cover how to use these operations in detail. We will
  609. present the rest of the operations in the next chapter.
  610. @table @option
  611. @item --create
  612. @itemx -c
  613. Create a new @command{tar} archive.
  614. @item --list
  615. @itemx -t
  616. List the contents of an archive.
  617. @item --extract
  618. @itemx -x
  619. Extract one or more members from an archive.
  620. @end table
  621. @node Two Frequent Options
  622. @section Two Frequently Used Options
  623. To understand how to run @command{tar} in the three operating modes listed
  624. previously, you also need to understand how to use two of the options to
  625. @command{tar}: @option{--file} (which takes an archive file as an argument)
  626. and @option{--verbose}. (You are usually not @emph{required} to specify
  627. either of these options when you run @command{tar}, but they can be very
  628. useful in making things more clear and helping you avoid errors.)
  629. @menu
  630. * file tutorial::
  631. * verbose tutorial::
  632. * help tutorial::
  633. @end menu
  634. @node file tutorial
  635. @unnumberedsubsec The @option{--file} Option
  636. @table @option
  637. @opindex file, tutorial
  638. @item --file=@var{archive-name}
  639. @itemx -f @var{archive-name}
  640. Specify the name of an archive file.
  641. @end table
  642. You can specify an argument for the @option{--file=@var{archive-name}} (@option{-f @var{archive-name}}) option whenever you
  643. use @command{tar}; this option determines the name of the archive file
  644. that @command{tar} will work on.
  645. @vrindex TAPE
  646. If you don't specify this argument, then @command{tar} will examine
  647. the environment variable @env{TAPE}. If it is set, its value will be
  648. used as the archive name. Otherwise, @command{tar} will use the
  649. default archive, determined at the compile time. Usually it is
  650. standard output or some physical tape drive attached to your machine
  651. (you can verify what the default is by running @kbd{tar
  652. --show-defaults}, @pxref{defaults}). If there is no tape drive
  653. attached, or the default is not meaningful, then @command{tar} will
  654. print an error message. The error message might look roughly like one
  655. of the following:
  656. @smallexample
  657. tar: can't open /dev/rmt8 : No such device or address
  658. tar: can't open /dev/rsmt0 : I/O error
  659. @end smallexample
  660. @noindent
  661. To avoid confusion, we recommend that you always specify an archive file
  662. name by using @option{--file=@var{archive-name}} (@option{-f @var{archive-name}}) when writing your @command{tar} commands.
  663. For more information on using the @option{--file=@var{archive-name}} (@option{-f @var{archive-name}}) option, see
  664. @ref{file}.
  665. @node verbose tutorial
  666. @unnumberedsubsec The @option{--verbose} Option
  667. @table @option
  668. @opindex verbose, introduced
  669. @item --verbose
  670. @itemx -v
  671. Show the files being worked on as @command{tar} is running.
  672. @end table
  673. @option{--verbose} (@option{-v}) shows details about the results of running
  674. @command{tar}. This can be especially useful when the results might not be
  675. obvious. For example, if you want to see the progress of @command{tar} as
  676. it writes files into the archive, you can use the @option{--verbose}
  677. option. In the beginning, you may find it useful to use
  678. @option{--verbose} at all times; when you are more accustomed to
  679. @command{tar}, you will likely want to use it at certain times but not at
  680. others. We will use @option{--verbose} at times to help make something
  681. clear, and we will give many examples both using and not using
  682. @option{--verbose} to show the differences.
  683. Sometimes, a single instance of @option{--verbose} on the command line
  684. will show a full, @samp{ls} style listing of an archive or files,
  685. giving sizes, owners, and similar information. @FIXME{Describe the
  686. exact output format, e.g., how hard links are displayed.}
  687. Other times, @option{--verbose} will only show files or members that the particular
  688. operation is operating on at the time. In the latter case, you can
  689. use @option{--verbose} twice in a command to get a listing such as that
  690. in the former case. For example, instead of saying
  691. @smallexample
  692. @kbd{tar -cvf afiles.tar apple angst aspic}
  693. @end smallexample
  694. @noindent
  695. above, you might say
  696. @smallexample
  697. @kbd{tar -cvvf afiles.tar apple angst aspic}
  698. @end smallexample
  699. @noindent
  700. This works equally well using short or long forms of options. Using
  701. long forms, you would simply write out the mnemonic form of the option
  702. twice, like this:
  703. @smallexample
  704. $ @kbd{tar --create --verbose --verbose @dots{}}
  705. @end smallexample
  706. @noindent
  707. Note that you must double the hyphens properly each time.
  708. Later in the tutorial, we will give examples using @w{@option{--verbose
  709. --verbose}}.
  710. @node help tutorial
  711. @unnumberedsubsec Getting Help: Using the @option{--help} Option
  712. @table @option
  713. @opindex help
  714. @item --help
  715. The @option{--help} option to @command{tar} prints out a very brief list of
  716. all operations and option available for the current version of
  717. @command{tar} available on your system.
  718. @end table
  719. @node create
  720. @section How to Create Archives
  721. @UNREVISED
  722. @cindex Creation of the archive
  723. @cindex Archive, creation of
  724. One of the basic operations of @command{tar} is @option{--create} (@option{-c}), which
  725. you use to create a @command{tar} archive. We will explain
  726. @option{--create} first because, in order to learn about the other
  727. operations, you will find it useful to have an archive available to
  728. practice on.
  729. To make this easier, in this section you will first create a directory
  730. containing three files. Then, we will show you how to create an
  731. @emph{archive} (inside the new directory). Both the directory, and
  732. the archive are specifically for you to practice on. The rest of this
  733. chapter and the next chapter will show many examples using this
  734. directory and the files you will create: some of those files may be
  735. other directories and other archives.
  736. The three files you will archive in this example are called
  737. @file{blues}, @file{folk}, and @file{jazz}. The archive is called
  738. @file{collection.tar}.
  739. This section will proceed slowly, detailing how to use @option{--create}
  740. in @code{verbose} mode, and showing examples using both short and long
  741. forms. In the rest of the tutorial, and in the examples in the next
  742. chapter, we will proceed at a slightly quicker pace. This section
  743. moves more slowly to allow beginning users to understand how
  744. @command{tar} works.
  745. @menu
  746. * prepare for examples::
  747. * Creating the archive::
  748. * create verbose::
  749. * short create::
  750. * create dir::
  751. @end menu
  752. @node prepare for examples
  753. @subsection Preparing a Practice Directory for Examples
  754. To follow along with this and future examples, create a new directory
  755. called @file{practice} containing files called @file{blues}, @file{folk}
  756. and @file{jazz}. The files can contain any information you like:
  757. ideally, they should contain information which relates to their names,
  758. and be of different lengths. Our examples assume that @file{practice}
  759. is a subdirectory of your home directory.
  760. Now @command{cd} to the directory named @file{practice}; @file{practice}
  761. is now your @dfn{working directory}. (@emph{Please note}: Although
  762. the full path name of this directory is
  763. @file{/@var{homedir}/practice}, in our examples we will refer to
  764. this directory as @file{practice}; the @var{homedir} is presumed.
  765. In general, you should check that the files to be archived exist where
  766. you think they do (in the working directory) by running @command{ls}.
  767. Because you just created the directory and the files and have changed to
  768. that directory, you probably don't need to do that this time.
  769. It is very important to make sure there isn't already a file in the
  770. working directory with the archive name you intend to use (in this case,
  771. @samp{collection.tar}), or that you don't care about its contents.
  772. Whenever you use @samp{create}, @command{tar} will erase the current
  773. contents of the file named by @option{--file=@var{archive-name}} (@option{-f @var{archive-name}}) if it exists. @command{tar}
  774. will not tell you if you are about to overwrite an archive unless you
  775. specify an option which does this (@pxref{backup}, for the
  776. information on how to do so). To add files to an existing archive,
  777. you need to use a different option, such as @option{--append} (@option{-r}); see
  778. @ref{append} for information on how to do this.
  779. @node Creating the archive
  780. @subsection Creating the Archive
  781. @opindex create, introduced
  782. To place the files @file{blues}, @file{folk}, and @file{jazz} into an
  783. archive named @file{collection.tar}, use the following command:
  784. @smallexample
  785. $ @kbd{tar --create --file=collection.tar blues folk jazz}
  786. @end smallexample
  787. The order of the arguments is not very important, @emph{when using long
  788. option forms}. You could also say:
  789. @smallexample
  790. $ @kbd{tar blues --create folk --file=collection.tar jazz}
  791. @end smallexample
  792. @noindent
  793. However, you can see that this order is harder to understand; this is
  794. why we will list the arguments in the order that makes the commands
  795. easiest to understand (and we encourage you to do the same when you use
  796. @command{tar}, to avoid errors).
  797. Note that the part of the command which says,
  798. @w{@option{--file=collection.tar}} is considered to be @emph{one} argument.
  799. If you substituted any other string of characters for
  800. @kbd{collection.tar}, then that string would become the name of the
  801. archive file you create.
  802. The order of the options becomes more important when you begin to use
  803. short forms. With short forms, if you type commands in the wrong order
  804. (even if you type them correctly in all other ways), you may end up with
  805. results you don't expect. For this reason, it is a good idea to get
  806. into the habit of typing options in the order that makes inherent sense.
  807. @xref{short create}, for more information on this.
  808. In this example, you type the command as shown above: @option{--create}
  809. is the operation which creates the new archive
  810. (@file{collection.tar}), and @option{--file} is the option which lets
  811. you give it the name you chose. The files, @file{blues}, @file{folk},
  812. and @file{jazz}, are now members of the archive, @file{collection.tar}
  813. (they are @dfn{file name arguments} to the @option{--create} operation.
  814. @xref{Choosing}, for the detailed discussion on these.) Now that they are
  815. in the archive, they are called @emph{archive members}, not files.
  816. (@pxref{Definitions,members}).
  817. When you create an archive, you @emph{must} specify which files you
  818. want placed in the archive. If you do not specify any archive
  819. members, @GNUTAR{} will complain.
  820. If you now list the contents of the working directory (@command{ls}), you will
  821. find the archive file listed as well as the files you saw previously:
  822. @smallexample
  823. blues folk jazz collection.tar
  824. @end smallexample
  825. @noindent
  826. Creating the archive @samp{collection.tar} did not destroy the copies of
  827. the files in the directory.
  828. Keep in mind that if you don't indicate an operation, @command{tar} will not
  829. run and will prompt you for one. If you don't name any files, @command{tar}
  830. will complain. You must have write access to the working directory,
  831. or else you will not be able to create an archive in that directory.
  832. @emph{Caution}: Do not attempt to use @option{--create} (@option{-c}) to add files to
  833. an existing archive; it will delete the archive and write a new one.
  834. Use @option{--append} (@option{-r}) instead. @xref{append}.
  835. @node create verbose
  836. @subsection Running @option{--create} with @option{--verbose}
  837. @opindex create, using with @option{--verbose}
  838. @opindex verbose, using with @option{--create}
  839. If you include the @option{--verbose} (@option{-v}) option on the command line,
  840. @command{tar} will list the files it is acting on as it is working. In
  841. verbose mode, the @code{create} example above would appear as:
  842. @smallexample
  843. $ @kbd{tar --create --verbose --file=collection.tar blues folk jazz}
  844. blues
  845. folk
  846. jazz
  847. @end smallexample
  848. This example is just like the example we showed which did not use
  849. @option{--verbose}, except that @command{tar} generated the remaining lines
  850. @iftex
  851. (note the different font styles).
  852. @end iftex
  853. @ifinfo
  854. .
  855. @end ifinfo
  856. In the rest of the examples in this chapter, we will frequently use
  857. @code{verbose} mode so we can show actions or @command{tar} responses that
  858. you would otherwise not see, and which are important for you to
  859. understand.
  860. @node short create
  861. @subsection Short Forms with @samp{create}
  862. As we said before, the @option{--create} (@option{-c}) operation is one of the most
  863. basic uses of @command{tar}, and you will use it countless times.
  864. Eventually, you will probably want to use abbreviated (or ``short'')
  865. forms of options. A full discussion of the three different forms that
  866. options can take appears in @ref{Styles}; for now, here is what the
  867. previous example (including the @option{--verbose} (@option{-v}) option) looks like
  868. using short option forms:
  869. @smallexample
  870. $ @kbd{tar -cvf collection.tar blues folk jazz}
  871. blues
  872. folk
  873. jazz
  874. @end smallexample
  875. @noindent
  876. As you can see, the system responds the same no matter whether you use
  877. long or short option forms.
  878. @FIXME{i don't like how this is worded:} One difference between using
  879. short and long option forms is that, although the exact placement of
  880. arguments following options is no more specific when using short forms,
  881. it is easier to become confused and make a mistake when using short
  882. forms. For example, suppose you attempted the above example in the
  883. following way:
  884. @smallexample
  885. $ @kbd{tar -cfv collection.tar blues folk jazz}
  886. @end smallexample
  887. @noindent
  888. In this case, @command{tar} will make an archive file called @file{v},
  889. containing the files @file{blues}, @file{folk}, and @file{jazz}, because
  890. the @samp{v} is the closest ``file name'' to the @option{-f} option, and
  891. is thus taken to be the chosen archive file name. @command{tar} will try
  892. to add a file called @file{collection.tar} to the @file{v} archive file;
  893. if the file @file{collection.tar} did not already exist, @command{tar} will
  894. report an error indicating that this file does not exist. If the file
  895. @file{collection.tar} does already exist (e.g., from a previous command
  896. you may have run), then @command{tar} will add this file to the archive.
  897. Because the @option{-v} option did not get registered, @command{tar} will not
  898. run under @samp{verbose} mode, and will not report its progress.
  899. The end result is that you may be quite confused about what happened,
  900. and possibly overwrite a file. To illustrate this further, we will show
  901. you how an example we showed previously would look using short forms.
  902. This example,
  903. @smallexample
  904. $ @kbd{tar blues --create folk --file=collection.tar jazz}
  905. @end smallexample
  906. @noindent
  907. is confusing as it is. When shown using short forms, however, it
  908. becomes much more so:
  909. @smallexample
  910. $ @kbd{tar blues -c folk -f collection.tar jazz}
  911. @end smallexample
  912. @noindent
  913. It would be very easy to put the wrong string of characters
  914. immediately following the @option{-f}, but doing that could sacrifice
  915. valuable data.
  916. For this reason, we recommend that you pay very careful attention to
  917. the order of options and placement of file and archive names,
  918. especially when using short option forms. Not having the option name
  919. written out mnemonically can affect how well you remember which option
  920. does what, and therefore where different names have to be placed.
  921. @node create dir
  922. @subsection Archiving Directories
  923. @cindex Archiving Directories
  924. @cindex Directories, Archiving
  925. You can archive a directory by specifying its directory name as a
  926. file name argument to @command{tar}. The files in the directory will be
  927. archived relative to the working directory, and the directory will be
  928. re-created along with its contents when the archive is extracted.
  929. To archive a directory, first move to its superior directory. If you
  930. have followed the previous instructions in this tutorial, you should
  931. type:
  932. @smallexample
  933. $ @kbd{cd ..}
  934. $
  935. @end smallexample
  936. @noindent
  937. This will put you into the directory which contains @file{practice},
  938. i.e., your home directory. Once in the superior directory, you can
  939. specify the subdirectory, @file{practice}, as a file name argument. To
  940. store @file{practice} in the new archive file @file{music.tar}, type:
  941. @smallexample
  942. $ @kbd{tar --create --verbose --file=music.tar practice}
  943. @end smallexample
  944. @noindent
  945. @command{tar} should output:
  946. @smallexample
  947. practice/
  948. practice/blues
  949. practice/folk
  950. practice/jazz
  951. practice/collection.tar
  952. @end smallexample
  953. Note that the archive thus created is not in the subdirectory
  954. @file{practice}, but rather in the current working directory---the
  955. directory from which @command{tar} was invoked. Before trying to archive a
  956. directory from its superior directory, you should make sure you have
  957. write access to the superior directory itself, not only the directory
  958. you are trying archive with @command{tar}. For example, you will probably
  959. not be able to store your home directory in an archive by invoking
  960. @command{tar} from the root directory; @xref{absolute}. (Note
  961. also that @file{collection.tar}, the original archive file, has itself
  962. been archived. @command{tar} will accept any file as a file to be
  963. archived, regardless of its content. When @file{music.tar} is
  964. extracted, the archive file @file{collection.tar} will be re-written
  965. into the file system).
  966. If you give @command{tar} a command such as
  967. @smallexample
  968. $ @kbd{tar --create --file=foo.tar .}
  969. @end smallexample
  970. @noindent
  971. @command{tar} will report @samp{tar: ./foo.tar is the archive; not
  972. dumped}. This happens because @command{tar} creates the archive
  973. @file{foo.tar} in the current directory before putting any files into
  974. it. Then, when @command{tar} attempts to add all the files in the
  975. directory @file{.} to the archive, it notices that the file
  976. @file{./foo.tar} is the same as the archive @file{foo.tar}, and skips
  977. it. (It makes no sense to put an archive into itself.) @GNUTAR{}
  978. will continue in this case, and create the archive
  979. normally, except for the exclusion of that one file. (@emph{Please
  980. note:} Other implementations of @command{tar} may not be so clever;
  981. they will enter an infinite loop when this happens, so you should not
  982. depend on this behavior unless you are certain you are running
  983. @GNUTAR{}. In general, it is wise to always place the archive outside
  984. of the directory being dumped.
  985. @node list
  986. @section How to List Archives
  987. @opindex list
  988. Frequently, you will find yourself wanting to determine exactly what a
  989. particular archive contains. You can use the @option{--list} (@option{-t}) operation
  990. to get the member names as they currently appear in the archive, as well
  991. as various attributes of the files at the time they were archived. For
  992. example, you can examine the archive @file{collection.tar} that you
  993. created in the last section with the command,
  994. @smallexample
  995. $ @kbd{tar --list --file=collection.tar}
  996. @end smallexample
  997. @noindent
  998. The output of @command{tar} would then be:
  999. @smallexample
  1000. blues
  1001. folk
  1002. jazz
  1003. @end smallexample
  1004. @noindent
  1005. The archive @file{bfiles.tar} would list as follows:
  1006. @smallexample
  1007. ./birds
  1008. baboon
  1009. ./box
  1010. @end smallexample
  1011. @noindent
  1012. Be sure to use a @option{--file=@var{archive-name}} (@option{-f
  1013. @var{archive-name}}) option just as with @option{--create}
  1014. (@option{-c}) to specify the name of the archive.
  1015. @opindex list, using with @option{--verbose}
  1016. @opindex verbose, using with @option{--list}
  1017. If you use the @option{--verbose} (@option{-v}) option with
  1018. @option{--list}, then @command{tar} will print out a listing
  1019. reminiscent of @w{@samp{ls -l}}, showing owner, file size, and so forth.
  1020. If you had used @option{--verbose} (@option{-v}) mode, the example
  1021. above would look like:
  1022. @smallexample
  1023. $ @kbd{tar --list --verbose --file=collection.tar folk}
  1024. -rw-r--r-- myself user 62 1990-05-23 10:55 folk
  1025. @end smallexample
  1026. @cindex listing member and file names
  1027. @anchor{listing member and file names}
  1028. It is important to notice that the output of @kbd{tar --list
  1029. --verbose} does not necessarily match that produced by @kbd{tar
  1030. --create --verbose} while creating the archive. It is because
  1031. @GNUTAR{}, unless told explicitly not to do so, removes some directory
  1032. prefixes from file names before storing them in the archive
  1033. (@xref{absolute}, for more information). In other
  1034. words, in verbose mode @GNUTAR{} shows @dfn{file names} when creating
  1035. an archive and @dfn{member names} when listing it. Consider this
  1036. example:
  1037. @smallexample
  1038. @group
  1039. $ @kbd{tar cfv archive /etc/mail}
  1040. tar: Removing leading `/' from member names
  1041. /etc/mail/
  1042. /etc/mail/sendmail.cf
  1043. /etc/mail/aliases
  1044. $ @kbd{tar tf archive}
  1045. etc/mail/
  1046. etc/mail/sendmail.cf
  1047. etc/mail/aliases
  1048. @end group
  1049. @end smallexample
  1050. @opindex show-stored-names
  1051. This default behavior can sometimes be inconvenient. You can force
  1052. @GNUTAR{} show member names when creating archive by supplying
  1053. @option{--show-stored-names} option.
  1054. @table @option
  1055. @item --show-stored-names
  1056. Print member (as opposed to @emph{file}) names when creating the archive.
  1057. @end table
  1058. @cindex File name arguments, using @option{--list} with
  1059. @opindex list, using with file name arguments
  1060. You can specify one or more individual member names as arguments when
  1061. using @samp{list}. In this case, @command{tar} will only list the
  1062. names of members you identify. For example, @w{@kbd{tar --list
  1063. --file=afiles.tar apple}} would only print @file{apple}.
  1064. Because @command{tar} preserves paths, file names must be specified as
  1065. they appear in the archive (ie., relative to the directory from which
  1066. the archive was created). Therefore, it is essential when specifying
  1067. member names to @command{tar} that you give the exact member names.
  1068. For example, @w{@kbd{tar --list --file=bfiles.tar birds}} would produce an
  1069. error message something like @samp{tar: birds: Not found in archive},
  1070. because there is no member named @file{birds}, only one named
  1071. @file{./birds}. While the names @file{birds} and @file{./birds} name
  1072. the same file, @emph{member} names by default are compared verbatim.
  1073. However, @w{@kbd{tar --list --file=bfiles.tar baboon}} would respond
  1074. with @file{baboon}, because this exact member name is in the archive file
  1075. @file{bfiles.tar}. If you are not sure of the exact file name,
  1076. use @dfn{globbing patterns}, for example:
  1077. @smallexample
  1078. $ @kbd{tar --list --file=bfiles.tar --wildcards '*b*'}
  1079. @end smallexample
  1080. @noindent
  1081. will list all members whose name contains @samp{b}. @xref{wildcards},
  1082. for a detailed discussion of globbing patterns and related
  1083. @command{tar} command line options.
  1084. @menu
  1085. * list dir::
  1086. @end menu
  1087. @node list dir
  1088. @unnumberedsubsec Listing the Contents of a Stored Directory
  1089. To get information about the contents of an archived directory,
  1090. use the directory name as a file name argument in conjunction with
  1091. @option{--list} (@option{-t}). To find out file attributes, include the
  1092. @option{--verbose} (@option{-v}) option.
  1093. For example, to find out about files in the directory @file{practice}, in
  1094. the archive file @file{music.tar}, type:
  1095. @smallexample
  1096. $ @kbd{tar --list --verbose --file=music.tar practice}
  1097. @end smallexample
  1098. @command{tar} responds:
  1099. @smallexample
  1100. drwxrwxrwx myself user 0 1990-05-31 21:49 practice/
  1101. -rw-r--r-- myself user 42 1990-05-21 13:29 practice/blues
  1102. -rw-r--r-- myself user 62 1990-05-23 10:55 practice/folk
  1103. -rw-r--r-- myself user 40 1990-05-21 13:30 practice/jazz
  1104. -rw-r--r-- myself user 10240 1990-05-31 21:49 practice/collection.tar
  1105. @end smallexample
  1106. When you use a directory name as a file name argument, @command{tar} acts on
  1107. all the files (including sub-directories) in that directory.
  1108. @node extract
  1109. @section How to Extract Members from an Archive
  1110. @UNREVISED
  1111. @cindex Extraction
  1112. @cindex Retrieving files from an archive
  1113. @cindex Resurrecting files from an archive
  1114. @opindex extract
  1115. Creating an archive is only half the job---there is no point in storing
  1116. files in an archive if you can't retrieve them. The act of retrieving
  1117. members from an archive so they can be used and manipulated as
  1118. unarchived files again is called @dfn{extraction}. To extract files
  1119. from an archive, use the @option{--extract} (@option{--get} or
  1120. @option{-x}) operation. As with @option{--create}, specify the name
  1121. of the archive with @option{--file} (@option{-f}) option. Extracting
  1122. an archive does not modify the archive in any way; you can extract it
  1123. multiple times if you want or need to.
  1124. Using @option{--extract}, you can extract an entire archive, or specific
  1125. files. The files can be directories containing other files, or not. As
  1126. with @option{--create} (@option{-c}) and @option{--list} (@option{-t}), you may use the short or the
  1127. long form of the operation without affecting the performance.
  1128. @menu
  1129. * extracting archives::
  1130. * extracting files::
  1131. * extract dir::
  1132. * extracting untrusted archives::
  1133. * failing commands::
  1134. @end menu
  1135. @node extracting archives
  1136. @subsection Extracting an Entire Archive
  1137. To extract an entire archive, specify the archive file name only, with
  1138. no individual file names as arguments. For example,
  1139. @smallexample
  1140. $ @kbd{tar -xvf collection.tar}
  1141. @end smallexample
  1142. @noindent
  1143. produces this:
  1144. @smallexample
  1145. -rw-r--r-- me user 28 1996-10-18 16:31 jazz
  1146. -rw-r--r-- me user 21 1996-09-23 16:44 blues
  1147. -rw-r--r-- me user 20 1996-09-23 16:44 folk
  1148. @end smallexample
  1149. @node extracting files
  1150. @subsection Extracting Specific Files
  1151. To extract specific archive members, give their exact member names as
  1152. arguments, as printed by @option{--list} (@option{-t}). If you had
  1153. mistakenly deleted one of the files you had placed in the archive
  1154. @file{collection.tar} earlier (say, @file{blues}), you can extract it
  1155. from the archive without changing the archive's structure. Its
  1156. contents will be identical to the original file @file{blues} that you
  1157. deleted.
  1158. First, make sure you are in the @file{practice} directory, and list the
  1159. files in the directory. Now, delete the file, @samp{blues}, and list
  1160. the files in the directory again.
  1161. You can now extract the member @file{blues} from the archive file
  1162. @file{collection.tar} like this:
  1163. @smallexample
  1164. $ @kbd{tar --extract --file=collection.tar blues}
  1165. @end smallexample
  1166. @noindent
  1167. If you list the files in the directory again, you will see that the file
  1168. @file{blues} has been restored, with its original permissions, data
  1169. modification times, and owner.@footnote{This is only accidentally
  1170. true, but not in general. Whereas modification times are always
  1171. restored, in most cases, one has to be root for restoring the owner,
  1172. and use a special option for restoring permissions. Here, it just
  1173. happens that the restoring user is also the owner of the archived
  1174. members, and that the current @code{umask} is compatible with original
  1175. permissions.} (These parameters will be identical to those which
  1176. the file had when you originally placed it in the archive; any changes
  1177. you may have made before deleting the file from the file system,
  1178. however, will @emph{not} have been made to the archive member.) The
  1179. archive file, @samp{collection.tar}, is the same as it was before you
  1180. extracted @samp{blues}. You can confirm this by running @command{tar} with
  1181. @option{--list} (@option{-t}).
  1182. Remember that as with other operations, specifying the exact member
  1183. name is important. @w{@kbd{tar --extract --file=bfiles.tar birds}}
  1184. will fail, because there is no member named @file{birds}. To extract
  1185. the member named @file{./birds}, you must specify @w{@kbd{tar
  1186. --extract --file=bfiles.tar ./birds}}. If you don't remember the
  1187. exact member names, use @option{--list} (@option{-t}) option
  1188. (@pxref{list}). You can also extract those members that match a
  1189. specific @dfn{globbing pattern}. For example, to extract from
  1190. @file{bfiles.tar} all files that begin with @samp{b}, no matter their
  1191. directory prefix, you could type:
  1192. @smallexample
  1193. $ @kbd{tar -x -f bfiles.tar --wildcards --no-anchored 'b*'}
  1194. @end smallexample
  1195. @noindent
  1196. Here, @option{--wildcards} instructs @command{tar} to treat
  1197. command line arguments as globbing patterns and @option{--no-anchored}
  1198. informs it that the patterns apply to member names after any @samp{/}
  1199. delimiter. The use of globbing patterns is discussed in detail in
  1200. @xref{wildcards}.
  1201. You can extract a file to standard output by combining the above options
  1202. with the @option{--to-stdout} (@option{-O}) option (@pxref{Writing to Standard
  1203. Output}).
  1204. If you give the @option{--verbose} option, then @option{--extract}
  1205. will print the names of the archive members as it extracts them.
  1206. @node extract dir
  1207. @subsection Extracting Files that are Directories
  1208. Extracting directories which are members of an archive is similar to
  1209. extracting other files. The main difference to be aware of is that if
  1210. the extracted directory has the same name as any directory already in
  1211. the working directory, then files in the extracted directory will be
  1212. placed into the directory of the same name. Likewise, if there are
  1213. files in the pre-existing directory with the same names as the members
  1214. which you extract, the files from the extracted archive will replace
  1215. the files already in the working directory (and possible
  1216. subdirectories). This will happen regardless of whether or not the
  1217. files in the working directory were more recent than those extracted
  1218. (there exist, however, special options that alter this behavior
  1219. @pxref{Writing}).
  1220. However, if a file was stored with a directory name as part of its file
  1221. name, and that directory does not exist under the working directory when
  1222. the file is extracted, @command{tar} will create the directory.
  1223. We can demonstrate how to use @option{--extract} to extract a directory
  1224. file with an example. Change to the @file{practice} directory if you
  1225. weren't there, and remove the files @file{folk} and @file{jazz}. Then,
  1226. go back to the parent directory and extract the archive
  1227. @file{music.tar}. You may either extract the entire archive, or you may
  1228. extract only the files you just deleted. To extract the entire archive,
  1229. don't give any file names as arguments after the archive name
  1230. @file{music.tar}. To extract only the files you deleted, use the
  1231. following command:
  1232. @smallexample
  1233. $ @kbd{tar -xvf music.tar practice/folk practice/jazz}
  1234. practice/folk
  1235. practice/jazz
  1236. @end smallexample
  1237. @noindent
  1238. If you were to specify two @option{--verbose} (@option{-v}) options, @command{tar}
  1239. would have displayed more detail about the extracted files, as shown
  1240. in the example below:
  1241. @smallexample
  1242. $ @kbd{tar -xvvf music.tar practice/folk practice/jazz}
  1243. -rw-r--r-- me user 28 1996-10-18 16:31 practice/jazz
  1244. -rw-r--r-- me user 20 1996-09-23 16:44 practice/folk
  1245. @end smallexample
  1246. @noindent
  1247. Because you created the directory with @file{practice} as part of the
  1248. file names of each of the files by archiving the @file{practice}
  1249. directory as @file{practice}, you must give @file{practice} as part
  1250. of the file names when you extract those files from the archive.
  1251. @node extracting untrusted archives
  1252. @subsection Extracting Archives from Untrusted Sources
  1253. Extracting files from archives can overwrite files that already exist.
  1254. If you receive an archive from an untrusted source, you should make a
  1255. new directory and extract into that directory, so that you don't have
  1256. to worry about the extraction overwriting one of your existing files.
  1257. For example, if @file{untrusted.tar} came from somewhere else on the
  1258. Internet, and you don't necessarily trust its contents, you can
  1259. extract it as follows:
  1260. @smallexample
  1261. $ @kbd{mkdir newdir}
  1262. $ @kbd{cd newdir}
  1263. $ @kbd{tar -xvf ../untrusted.tar}
  1264. @end smallexample
  1265. It is also a good practice to examine contents of the archive
  1266. before extracting it, using @option{--list} (@option{-t}) option, possibly combined
  1267. with @option{--verbose} (@option{-v}).
  1268. @node failing commands
  1269. @subsection Commands That Will Fail
  1270. Here are some sample commands you might try which will not work, and why
  1271. they won't work.
  1272. If you try to use this command,
  1273. @smallexample
  1274. $ @kbd{tar -xvf music.tar folk jazz}
  1275. @end smallexample
  1276. @noindent
  1277. you will get the following response:
  1278. @smallexample
  1279. tar: folk: Not found in archive
  1280. tar: jazz: Not found in archive
  1281. $
  1282. @end smallexample
  1283. @noindent
  1284. This is because these files were not originally @emph{in} the parent
  1285. directory @file{..}, where the archive is located; they were in the
  1286. @file{practice} directory, and their file names reflect this:
  1287. @smallexample
  1288. $ @kbd{tar -tvf music.tar}
  1289. practice/folk
  1290. practice/jazz
  1291. practice/rock
  1292. @end smallexample
  1293. @FIXME{make sure the above works when going through the examples in
  1294. order...}
  1295. @noindent
  1296. Likewise, if you try to use this command,
  1297. @smallexample
  1298. $ @kbd{tar -tvf music.tar folk jazz}
  1299. @end smallexample
  1300. @noindent
  1301. you would get a similar response. Members with those names are not in the
  1302. archive. You must use the correct member names, or wildcards, in order
  1303. to extract the files from the archive.
  1304. If you have forgotten the correct names of the files in the archive,
  1305. use @w{@kbd{tar --list --verbose}} to list them correctly.
  1306. @FIXME{more examples, here? hag thinks it's a good idea.}
  1307. @node going further
  1308. @section Going Further Ahead in this Manual
  1309. @FIXME{need to write up a node here about the things that are going to
  1310. be in the rest of the manual.}
  1311. @node tar invocation
  1312. @chapter Invoking @GNUTAR{}
  1313. @UNREVISED
  1314. This chapter is about how one invokes the @GNUTAR{}
  1315. command, from the command synopsis (@pxref{Synopsis}). There are
  1316. numerous options, and many styles for writing them. One mandatory
  1317. option specifies the operation @command{tar} should perform
  1318. (@pxref{Operation Summary}), other options are meant to detail how
  1319. this operation should be performed (@pxref{Option Summary}).
  1320. Non-option arguments are not always interpreted the same way,
  1321. depending on what the operation is.
  1322. You will find in this chapter everything about option styles and rules for
  1323. writing them (@pxref{Styles}). On the other hand, operations and options
  1324. are fully described elsewhere, in other chapters. Here, you will find
  1325. only synthetic descriptions for operations and options, together with
  1326. pointers to other parts of the @command{tar} manual.
  1327. Some options are so special they are fully described right in this
  1328. chapter. They have the effect of inhibiting the normal operation of
  1329. @command{tar} or else, they globally alter the amount of feedback the user
  1330. receives about what is going on. These are the @option{--help} and
  1331. @option{--version} (@pxref{help}), @option{--verbose} (@pxref{verbose})
  1332. and @option{--interactive} options (@pxref{interactive}).
  1333. @menu
  1334. * Synopsis::
  1335. * using tar options::
  1336. * Styles::
  1337. * All Options::
  1338. * help::
  1339. * defaults::
  1340. * verbose::
  1341. * interactive::
  1342. @end menu
  1343. @node Synopsis
  1344. @section General Synopsis of @command{tar}
  1345. The @GNUTAR{} program is invoked as either one of:
  1346. @smallexample
  1347. @kbd{tar @var{option}@dots{} [@var{name}]@dots{}}
  1348. @kbd{tar @var{letter}@dots{} [@var{argument}]@dots{} [@var{option}]@dots{} [@var{name}]@dots{}}
  1349. @end smallexample
  1350. The second form is for when old options are being used.
  1351. You can use @command{tar} to store files in an archive, to extract them from
  1352. an archive, and to do other types of archive manipulation. The primary
  1353. argument to @command{tar}, which is called the @dfn{operation}, specifies
  1354. which action to take. The other arguments to @command{tar} are either
  1355. @dfn{options}, which change the way @command{tar} performs an operation,
  1356. or file names or archive members, which specify the files or members
  1357. @command{tar} is to act on.
  1358. You can actually type in arguments in any order, even if in this manual
  1359. the options always precede the other arguments, to make examples easier
  1360. to understand. Further, the option stating the main operation mode
  1361. (the @command{tar} main command) is usually given first.
  1362. Each @var{name} in the synopsis above is interpreted as an archive member
  1363. name when the main command is one of @option{--compare}
  1364. (@option{--diff}, @option{-d}), @option{--delete}, @option{--extract}
  1365. (@option{--get}, @option{-x}), @option{--list} (@option{-t}) or
  1366. @option{--update} (@option{-u}). When naming archive members, you
  1367. must give the exact name of the member in the archive, as it is
  1368. printed by @option{--list}. For @option{--append} (@option{-r}) and
  1369. @option{--create} (@option{-c}), these @var{name} arguments specify
  1370. the names of either files or directory hierarchies to place in the archive.
  1371. These files or hierarchies should already exist in the file system,
  1372. prior to the execution of the @command{tar} command.
  1373. @command{tar} interprets relative file names as being relative to the
  1374. working directory. @command{tar} will make all file names relative
  1375. (by removing leading slashes when archiving or restoring files),
  1376. unless you specify otherwise (using the @option{--absolute-names}
  1377. option). @xref{absolute}, for more information about
  1378. @option{--absolute-names}.
  1379. If you give the name of a directory as either a file name or a member
  1380. name, then @command{tar} acts recursively on all the files and directories
  1381. beneath that directory. For example, the name @file{/} identifies all
  1382. the files in the file system to @command{tar}.
  1383. The distinction between file names and archive member names is especially
  1384. important when shell globbing is used, and sometimes a source of confusion
  1385. for newcomers. @xref{wildcards}, for more information about globbing.
  1386. The problem is that shells may only glob using existing files in the
  1387. file system. Only @command{tar} itself may glob on archive members, so when
  1388. needed, you must ensure that wildcard characters reach @command{tar} without
  1389. being interpreted by the shell first. Using a backslash before @samp{*}
  1390. or @samp{?}, or putting the whole argument between quotes, is usually
  1391. sufficient for this.
  1392. Even if @var{name}s are often specified on the command line, they
  1393. can also be read from a text file in the file system, using the
  1394. @option{--files-from=@var{file-of-names}} (@option{-T @var{file-of-names}}) option.
  1395. If you don't use any file name arguments, @option{--append} (@option{-r}),
  1396. @option{--delete} and @option{--concatenate} (@option{--catenate},
  1397. @option{-A}) will do nothing, while @option{--create} (@option{-c})
  1398. will usually yield a diagnostic and inhibit @command{tar} execution.
  1399. The other operations of @command{tar} (@option{--list},
  1400. @option{--extract}, @option{--compare}, and @option{--update})
  1401. will act on the entire contents of the archive.
  1402. @cindex exit status
  1403. @cindex return status
  1404. Besides successful exits, @GNUTAR{} may fail for
  1405. many reasons. Some reasons correspond to bad usage, that is, when the
  1406. @command{tar} command is improperly written. Errors may be
  1407. encountered later, while encountering an error processing the archive
  1408. or the files. Some errors are recoverable, in which case the failure
  1409. is delayed until @command{tar} has completed all its work. Some
  1410. errors are such that it would not meaningful, or at least risky, to
  1411. continue processing: @command{tar} then aborts processing immediately.
  1412. All abnormal exits, whether immediate or delayed, should always be
  1413. clearly diagnosed on @code{stderr}, after a line stating the nature of
  1414. the error.
  1415. @GNUTAR{} returns only a few exit statuses. I'm really
  1416. aiming simplicity in that area, for now. If you are not using the
  1417. @option{--compare} @option{--diff}, @option{-d}) option, zero means
  1418. that everything went well, besides maybe innocuous warnings. Nonzero
  1419. means that something went wrong. Right now, as of today, ``nonzero''
  1420. is almost always 2, except for remote operations, where it may be
  1421. 128.
  1422. @node using tar options
  1423. @section Using @command{tar} Options
  1424. @GNUTAR{} has a total of eight operating modes which
  1425. allow you to perform a variety of tasks. You are required to choose
  1426. one operating mode each time you employ the @command{tar} program by
  1427. specifying one, and only one operation as an argument to the
  1428. @command{tar} command (two lists of four operations each may be found
  1429. at @ref{frequent operations} and @ref{Operations}). Depending on
  1430. circumstances, you may also wish to customize how the chosen operating
  1431. mode behaves. For example, you may wish to change the way the output
  1432. looks, or the format of the files that you wish to archive may require
  1433. you to do something special in order to make the archive look right.
  1434. You can customize and control @command{tar}'s performance by running
  1435. @command{tar} with one or more options (such as @option{--verbose}
  1436. (@option{-v}), which we used in the tutorial). As we said in the
  1437. tutorial, @dfn{options} are arguments to @command{tar} which are (as
  1438. their name suggests) optional. Depending on the operating mode, you
  1439. may specify one or more options. Different options will have different
  1440. effects, but in general they all change details of the operation, such
  1441. as archive format, archive name, or level of user interaction. Some
  1442. options make sense with all operating modes, while others are
  1443. meaningful only with particular modes. You will likely use some
  1444. options frequently, while you will only use others infrequently, or
  1445. not at all. (A full list of options is available in @pxref{All Options}.)
  1446. @vrindex TAR_OPTIONS, environment variable
  1447. @anchor{TAR_OPTIONS}
  1448. The @env{TAR_OPTIONS} environment variable specifies default options to
  1449. be placed in front of any explicit options. For example, if
  1450. @code{TAR_OPTIONS} is @samp{-v --unlink-first}, @command{tar} behaves as
  1451. if the two options @option{-v} and @option{--unlink-first} had been
  1452. specified before any explicit options. Option specifications are
  1453. separated by whitespace. A backslash escapes the next character, so it
  1454. can be used to specify an option containing whitespace or a backslash.
  1455. Note that @command{tar} options are case sensitive. For example, the
  1456. options @option{-T} and @option{-t} are different; the first requires an
  1457. argument for stating the name of a file providing a list of @var{name}s,
  1458. while the second does not require an argument and is another way to
  1459. write @option{--list} (@option{-t}).
  1460. In addition to the eight operations, there are many options to
  1461. @command{tar}, and three different styles for writing both: long (mnemonic)
  1462. form, short form, and old style. These styles are discussed below.
  1463. Both the options and the operations can be written in any of these three
  1464. styles.
  1465. @FIXME{menu at end of this node. need to think of an actual outline
  1466. for this chapter; probably do that after stuff from chapter 4 is
  1467. incorporated.}
  1468. @node Styles
  1469. @section The Three Option Styles
  1470. There are three styles for writing operations and options to the command
  1471. line invoking @command{tar}. The different styles were developed at
  1472. different times during the history of @command{tar}. These styles will be
  1473. presented below, from the most recent to the oldest.
  1474. Some options must take an argument. (For example, @option{--file}
  1475. (@option{-f})) takes the name of an archive file as an argument. If
  1476. you do not supply an archive file name, @command{tar} will use a
  1477. default, but this can be confusing; thus, we recommend that you always
  1478. supply a specific archive file name.) Where you @emph{place} the
  1479. arguments generally depends on which style of options you choose. We
  1480. will detail specific information relevant to each option style in the
  1481. sections on the different option styles, below. The differences are
  1482. subtle, yet can often be very important; incorrect option placement
  1483. can cause you to overwrite a number of important files. We urge you
  1484. to note these differences, and only use the option style(s) which
  1485. makes the most sense to you until you feel comfortable with the others.
  1486. Some options @emph{may} take an argument (currently, there are
  1487. two such options: @option{--backup} and @option{--occurrence}). Such
  1488. options may have at most long and short forms, they do not have old style
  1489. equivalent. The rules for specifying an argument for such options
  1490. are stricter than those for specifying mandatory arguments. Please,
  1491. pay special attention to them.
  1492. @menu
  1493. * Mnemonic Options:: Mnemonic Option Style
  1494. * Short Options:: Short Option Style
  1495. * Old Options:: Old Option Style
  1496. * Mixing:: Mixing Option Styles
  1497. @end menu
  1498. @node Mnemonic Options
  1499. @subsection Mnemonic Option Style
  1500. @FIXME{have to decide whether or not to replace other occurrences of
  1501. "mnemonic" with "long", or *ugh* vice versa.}
  1502. Each option has at least one long (or mnemonic) name starting with two
  1503. dashes in a row, e.g., @option{--list}. The long names are more clear than
  1504. their corresponding short or old names. It sometimes happens that a
  1505. single mnemonic option has many different different names which are
  1506. synonymous, such as @option{--compare} and @option{--diff}. In addition,
  1507. long option names can be given unique abbreviations. For example,
  1508. @option{--cre} can be used in place of @option{--create} because there is no
  1509. other mnemonic option which begins with @samp{cre}. (One way to find
  1510. this out is by trying it and seeing what happens; if a particular
  1511. abbreviation could represent more than one option, @command{tar} will tell
  1512. you that that abbreviation is ambiguous and you'll know that that
  1513. abbreviation won't work. You may also choose to run @samp{tar --help}
  1514. to see a list of options. Be aware that if you run @command{tar} with a
  1515. unique abbreviation for the long name of an option you didn't want to
  1516. use, you are stuck; @command{tar} will perform the command as ordered.)
  1517. Mnemonic options are meant to be obvious and easy to remember, and their
  1518. meanings are generally easier to discern than those of their
  1519. corresponding short options (see below). For example:
  1520. @smallexample
  1521. $ @kbd{tar --create --verbose --blocking-factor=20 --file=/dev/rmt0}
  1522. @end smallexample
  1523. @noindent
  1524. gives a fairly good set of hints about what the command does, even
  1525. for those not fully acquainted with @command{tar}.
  1526. Mnemonic options which require arguments take those arguments
  1527. immediately following the option name. There are two ways of
  1528. specifying a mandatory argument. It can be separated from the
  1529. option name either by an equal sign, or by any amount of
  1530. white space characters. For example, the @option{--file} option (which
  1531. tells the name of the @command{tar} archive) is given a file such as
  1532. @file{archive.tar} as argument by using any of the following notations:
  1533. @option{--file=archive.tar} or @option{--file archive.tar}.
  1534. In contrast, optional arguments must always be introduced using
  1535. an equal sign. For example, the @option{--backup} option takes
  1536. an optional argument specifying backup type. It must be used
  1537. as @option{--backup=@var{backup-type}}.
  1538. @node Short Options
  1539. @subsection Short Option Style
  1540. Most options also have a short option name. Short options start with
  1541. a single dash, and are followed by a single character, e.g., @option{-t}
  1542. (which is equivalent to @option{--list}). The forms are absolutely
  1543. identical in function; they are interchangeable.
  1544. The short option names are faster to type than long option names.
  1545. Short options which require arguments take their arguments immediately
  1546. following the option, usually separated by white space. It is also
  1547. possible to stick the argument right after the short option name, using
  1548. no intervening space. For example, you might write @w{@option{-f
  1549. archive.tar}} or @option{-farchive.tar} instead of using
  1550. @option{--file=archive.tar}. Both @option{--file=@var{archive-name}} and
  1551. @w{@option{-f @var{archive-name}}} denote the option which indicates a
  1552. specific archive, here named @file{archive.tar}.
  1553. Short options which take optional arguments take their arguments
  1554. immediately following the option letter, @emph{without any intervening
  1555. white space characters}.
  1556. Short options' letters may be clumped together, but you are not
  1557. required to do this (as compared to old options; see below). When
  1558. short options are clumped as a set, use one (single) dash for them
  1559. all, e.g., @w{@samp{@command{tar} -cvf}}. Only the last option in
  1560. such a set is allowed to have an argument@footnote{Clustering many
  1561. options, the last of which has an argument, is a rather opaque way to
  1562. write options. Some wonder if @acronym{GNU} @code{getopt} should not
  1563. even be made helpful enough for considering such usages as invalid.}.
  1564. When the options are separated, the argument for each option which requires
  1565. an argument directly follows that option, as is usual for Unix programs.
  1566. For example:
  1567. @smallexample
  1568. $ @kbd{tar -c -v -b 20 -f /dev/rmt0}
  1569. @end smallexample
  1570. If you reorder short options' locations, be sure to move any arguments
  1571. that belong to them. If you do not move the arguments properly, you may
  1572. end up overwriting files.
  1573. @node Old Options
  1574. @subsection Old Option Style
  1575. @UNREVISED
  1576. Like short options, old options are single letters. However, old options
  1577. must be written together as a single clumped set, without spaces separating
  1578. them or dashes preceding them@footnote{Beware that if you precede options
  1579. with a dash, you are announcing the short option style instead of the
  1580. old option style; short options are decoded differently.}. This set
  1581. of letters must be the first to appear on the command line, after the
  1582. @command{tar} program name and some white space; old options cannot appear
  1583. anywhere else. The letter of an old option is exactly the same letter as
  1584. the corresponding short option. For example, the old option @samp{t} is
  1585. the same as the short option @option{-t}, and consequently, the same as the
  1586. mnemonic option @option{--list}. So for example, the command @w{@samp{tar
  1587. cv}} specifies the option @option{-v} in addition to the operation @option{-c}.
  1588. When options that need arguments are given together with the command,
  1589. all the associated arguments follow, in the same order as the options.
  1590. Thus, the example given previously could also be written in the old
  1591. style as follows:
  1592. @smallexample
  1593. $ @kbd{tar cvbf 20 /dev/rmt0}
  1594. @end smallexample
  1595. @noindent
  1596. Here, @samp{20} is the argument of @option{-b} and @samp{/dev/rmt0} is
  1597. the argument of @option{-f}.
  1598. On the other hand, this old style syntax makes it difficult to match
  1599. option letters with their corresponding arguments, and is often
  1600. confusing. In the command @w{@samp{tar cvbf 20 /dev/rmt0}}, for example,
  1601. @samp{20} is the argument for @option{-b}, @samp{/dev/rmt0} is the
  1602. argument for @option{-f}, and @option{-v} does not have a corresponding
  1603. argument. Even using short options like in @w{@samp{tar -c -v -b 20 -f
  1604. /dev/rmt0}} is clearer, putting all arguments next to the option they
  1605. pertain to.
  1606. If you want to reorder the letters in the old option argument, be
  1607. sure to reorder any corresponding argument appropriately.
  1608. This old way of writing @command{tar} options can surprise even experienced
  1609. users. For example, the two commands:
  1610. @smallexample
  1611. @kbd{tar cfz archive.tar.gz file}
  1612. @kbd{tar -cfz archive.tar.gz file}
  1613. @end smallexample
  1614. @noindent
  1615. are quite different. The first example uses @file{archive.tar.gz} as
  1616. the value for option @samp{f} and recognizes the option @samp{z}. The
  1617. second example, however, uses @file{z} as the value for option
  1618. @samp{f} --- probably not what was intended.
  1619. Old options are kept for compatibility with old versions of @command{tar}.
  1620. This second example could be corrected in many ways, among which the
  1621. following are equivalent:
  1622. @smallexample
  1623. @kbd{tar -czf archive.tar.gz file}
  1624. @kbd{tar -cf archive.tar.gz -z file}
  1625. @kbd{tar cf archive.tar.gz -z file}
  1626. @end smallexample
  1627. @cindex option syntax, traditional
  1628. As far as we know, all @command{tar} programs, @acronym{GNU} and
  1629. non-@acronym{GNU}, support old options. @GNUTAR{}
  1630. supports them not only for historical reasons, but also because many
  1631. people are used to them. For compatibility with Unix @command{tar},
  1632. the first argument is always treated as containing command and option
  1633. letters even if it doesn't start with @samp{-}. Thus, @samp{tar c} is
  1634. equivalent to @w{@samp{tar -c}:} both of them specify the
  1635. @option{--create} (@option{-c}) command to create an archive.
  1636. @node Mixing
  1637. @subsection Mixing Option Styles
  1638. All three styles may be intermixed in a single @command{tar} command,
  1639. so long as the rules for each style are fully
  1640. respected@footnote{Before @GNUTAR{} version 1.11.6,
  1641. a bug prevented intermixing old style options with mnemonic options in
  1642. some cases.}. Old style options and either of the modern styles of
  1643. options may be mixed within a single @command{tar} command. However,
  1644. old style options must be introduced as the first arguments only,
  1645. following the rule for old options (old options must appear directly
  1646. after the @command{tar} command and some white space). Modern options
  1647. may be given only after all arguments to the old options have been
  1648. collected. If this rule is not respected, a modern option might be
  1649. falsely interpreted as the value of the argument to one of the old
  1650. style options.
  1651. For example, all the following commands are wholly equivalent, and
  1652. illustrate the many combinations and orderings of option styles.
  1653. @smallexample
  1654. @kbd{tar --create --file=archive.tar}
  1655. @kbd{tar --create -f archive.tar}
  1656. @kbd{tar --create -farchive.tar}
  1657. @kbd{tar --file=archive.tar --create}
  1658. @kbd{tar --file=archive.tar -c}
  1659. @kbd{tar -c --file=archive.tar}
  1660. @kbd{tar -c -f archive.tar}
  1661. @kbd{tar -c -farchive.tar}
  1662. @kbd{tar -cf archive.tar}
  1663. @kbd{tar -cfarchive.tar}
  1664. @kbd{tar -f archive.tar --create}
  1665. @kbd{tar -f archive.tar -c}
  1666. @kbd{tar -farchive.tar --create}
  1667. @kbd{tar -farchive.tar -c}
  1668. @kbd{tar c --file=archive.tar}
  1669. @kbd{tar c -f archive.tar}
  1670. @kbd{tar c -farchive.tar}
  1671. @kbd{tar cf archive.tar}
  1672. @kbd{tar f archive.tar --create}
  1673. @kbd{tar f archive.tar -c}
  1674. @kbd{tar fc archive.tar}
  1675. @end smallexample
  1676. On the other hand, the following commands are @emph{not} equivalent to
  1677. the previous set:
  1678. @smallexample
  1679. @kbd{tar -f -c archive.tar}
  1680. @kbd{tar -fc archive.tar}
  1681. @kbd{tar -fcarchive.tar}
  1682. @kbd{tar -farchive.tarc}
  1683. @kbd{tar cfarchive.tar}
  1684. @end smallexample
  1685. @noindent
  1686. These last examples mean something completely different from what the
  1687. user intended (judging based on the example in the previous set which
  1688. uses long options, whose intent is therefore very clear). The first
  1689. four specify that the @command{tar} archive would be a file named
  1690. @option{-c}, @samp{c}, @samp{carchive.tar} or @samp{archive.tarc},
  1691. respectively. The first two examples also specify a single non-option,
  1692. @var{name} argument having the value @samp{archive.tar}. The last
  1693. example contains only old style option letters (repeating option
  1694. @samp{c} twice), not all of which are meaningful (eg., @samp{.},
  1695. @samp{h}, or @samp{i}), with no argument value. @FIXME{not sure i liked
  1696. the first sentence of this paragraph..}
  1697. @node All Options
  1698. @section All @command{tar} Options
  1699. The coming manual sections contain an alphabetical listing of all
  1700. @command{tar} operations and options, with brief descriptions and cross
  1701. references to more in-depth explanations in the body of the manual.
  1702. They also contain an alphabetically arranged table of the short option
  1703. forms with their corresponding long option. You can use this table as
  1704. a reference for deciphering @command{tar} commands in scripts.
  1705. @menu
  1706. * Operation Summary::
  1707. * Option Summary::
  1708. * Short Option Summary::
  1709. @end menu
  1710. @node Operation Summary
  1711. @subsection Operations
  1712. @table @option
  1713. @opindex append, summary
  1714. @item --append
  1715. @itemx -r
  1716. Appends files to the end of the archive. @xref{append}.
  1717. @opindex catenate, summary
  1718. @item --catenate
  1719. @itemx -A
  1720. Same as @option{--concatenate}. @xref{concatenate}.
  1721. @opindex compare, summary
  1722. @item --compare
  1723. @itemx -d
  1724. Compares archive members with their counterparts in the file
  1725. system, and reports differences in file size, mode, owner,
  1726. modification date and contents. @xref{compare}.
  1727. @opindex concatenate, summary
  1728. @item --concatenate
  1729. @itemx -A
  1730. Appends other @command{tar} archives to the end of the archive.
  1731. @xref{concatenate}.
  1732. @opindex create, summary
  1733. @item --create
  1734. @itemx -c
  1735. Creates a new @command{tar} archive. @xref{create}.
  1736. @opindex delete, summary
  1737. @item --delete
  1738. Deletes members from the archive. Don't try this on a archive on a
  1739. tape! @xref{delete}.
  1740. @opindex diff, summary
  1741. @item --diff
  1742. @itemx -d
  1743. Same @option{--compare}. @xref{compare}.
  1744. @opindex extract, summary
  1745. @item --extract
  1746. @itemx -x
  1747. Extracts members from the archive into the file system. @xref{extract}.
  1748. @opindex get, summary
  1749. @item --get
  1750. @itemx -x
  1751. Same as @option{--extract}. @xref{extract}.
  1752. @opindex list, summary
  1753. @item --list
  1754. @itemx -t
  1755. Lists the members in an archive. @xref{list}.
  1756. @opindex update, summary
  1757. @item --update
  1758. @itemx -u
  1759. Adds files to the end of the archive, but only if they are newer than
  1760. their counterparts already in the archive, or if they do not already
  1761. exist in the archive. @xref{update}.
  1762. @end table
  1763. @node Option Summary
  1764. @subsection @command{tar} Options
  1765. @table @option
  1766. @opindex absolute-names, summary
  1767. @item --absolute-names
  1768. @itemx -P
  1769. Normally when creating an archive, @command{tar} strips an initial
  1770. @samp{/} from member names. This option disables that behavior.
  1771. @xref{absolute}.
  1772. @opindex after-date, summary
  1773. @item --after-date
  1774. (See @option{--newer}, @pxref{after})
  1775. @opindex anchored, summary
  1776. @item --anchored
  1777. A pattern must match an initial subsequence of the name's components.
  1778. @xref{controlling pattern-matching}.
  1779. @opindex atime-preserve, summary
  1780. @item --atime-preserve
  1781. @itemx --atime-preserve=replace
  1782. @itemx --atime-preserve=system
  1783. Attempt to preserve the access time of files when reading them. This
  1784. option currently is effective only on files that you own, unless you
  1785. have superuser privileges.
  1786. @option{--atime-preserve=replace} remembers the access time of a file
  1787. before reading it, and then restores the access time afterwards. This
  1788. may cause problems if other programs are reading the file at the same
  1789. time, as the times of their accesses will be lost. On most platforms
  1790. restoring the access time also requires @command{tar} to restore the
  1791. data modification time too, so this option may also cause problems if
  1792. other programs are writing the file at the same time. (Tar attempts
  1793. to detect this situation, but cannot do so reliably due to race
  1794. conditions.) Worse, on most platforms restoring the access time also
  1795. updates the status change time, which means that this option is
  1796. incompatible with incremental backups.
  1797. @option{--atime-preserve=system} avoids changing time stamps on files,
  1798. without interfering with time stamp updates
  1799. caused by other programs, so it works better with incremental backups.
  1800. However, it requires a special @code{O_NOATIME} option from the
  1801. underlying operating and file system implementation, and it also requires
  1802. that searching directories does not update their access times. As of
  1803. this writing (November 2005) this works only with Linux, and only with
  1804. Linux kernels 2.6.8 and later. Worse, there is currently no reliable
  1805. way to know whether this feature actually works. Sometimes
  1806. @command{tar} knows that it does not work, and if you use
  1807. @option{--atime-preserve=system} then @command{tar} complains and
  1808. exits right away. But other times @command{tar} might think that the
  1809. option works when it actually does not.
  1810. Currently @option{--atime-preserve} with no operand defaults to
  1811. @option{--atime-preserve=replace}, but this may change in the future
  1812. as support for @option{--atime-preserve=system} improves.
  1813. If your operating system does not support
  1814. @option{--atime-preserve=system}, you might be able to preserve access
  1815. times reliably by by using the @command{mount} command. For example,
  1816. you can mount the file system read-only, or access the file system via
  1817. a read-only loopback mount, or use the @samp{noatime} mount option
  1818. available on some systems. However, mounting typically requires
  1819. superuser privileges and can be a pain to manage.
  1820. @opindex backup, summary
  1821. @item --backup=@var{backup-type}
  1822. Rather than deleting files from the file system, @command{tar} will
  1823. back them up using simple or numbered backups, depending upon
  1824. @var{backup-type}. @xref{backup}.
  1825. @opindex block-number, summary
  1826. @item --block-number
  1827. @itemx -R
  1828. With this option present, @command{tar} prints error messages for read errors
  1829. with the block number in the archive file. @xref{block-number}.
  1830. @opindex blocking-factor, summary
  1831. @item --blocking-factor=@var{blocking}
  1832. @itemx -b @var{blocking}
  1833. Sets the blocking factor @command{tar} uses to @var{blocking} x 512 bytes per
  1834. record. @xref{Blocking Factor}.
  1835. @opindex bzip2, summary
  1836. @item --bzip2
  1837. @itemx -j
  1838. This option tells @command{tar} to read or write archives through
  1839. @code{bzip2}. @xref{gzip}.
  1840. @opindex checkpoint, summary
  1841. @item --checkpoint[=@var{number}]
  1842. This option directs @command{tar} to print periodic checkpoint
  1843. messages as it reads through the archive. It is intended for when you
  1844. want a visual indication that @command{tar} is still running, but
  1845. don't want to see @option{--verbose} output. For a detailed
  1846. description, see @ref{Progress information}.
  1847. @opindex check-links, summary
  1848. @item --check-links
  1849. @itemx -l
  1850. If this option was given, @command{tar} will check the number of links
  1851. dumped for each processed file. If this number does not match the
  1852. total number of hard links for the file, a warning message will be
  1853. output @footnote{Earlier versions of @GNUTAR{} understood @option{-l} as a
  1854. synonym for @option{--one-file-system}. The current semantics, wich
  1855. complies to UNIX98, was introduced with version
  1856. 1.15.91. @xref{Changes}, for more information.}.
  1857. @opindex compress, summary
  1858. @opindex uncompress, summary
  1859. @item --compress
  1860. @itemx --uncompress
  1861. @itemx -Z
  1862. @command{tar} will use the @command{compress} program when reading or
  1863. writing the archive. This allows you to directly act on archives
  1864. while saving space. @xref{gzip}.
  1865. @opindex confirmation, summary
  1866. @item --confirmation
  1867. (See @option{--interactive}.) @xref{interactive}.
  1868. @opindex delay-directory-restore, summary
  1869. @item --delay-directory-restore
  1870. Delay setting modification times and permissions of extracted
  1871. directories until the end of extraction. @xref{Directory Modification Times and Permissions}.
  1872. @opindex dereference, summary
  1873. @item --dereference
  1874. @itemx -h
  1875. When creating a @command{tar} archive, @command{tar} will archive the
  1876. file that a symbolic link points to, rather than archiving the
  1877. symlink. @xref{dereference}.
  1878. @opindex directory, summary
  1879. @item --directory=@var{dir}
  1880. @itemx -C @var{dir}
  1881. When this option is specified, @command{tar} will change its current directory
  1882. to @var{dir} before performing any operations. When this option is used
  1883. during archive creation, it is order sensitive. @xref{directory}.
  1884. @opindex exclude, summary
  1885. @item --exclude=@var{pattern}
  1886. When performing operations, @command{tar} will skip files that match
  1887. @var{pattern}. @xref{exclude}.
  1888. @opindex exclude-from, summary
  1889. @item --exclude-from=@var{file}
  1890. @itemx -X @var{file}
  1891. Similar to @option{--exclude}, except @command{tar} will use the list of
  1892. patterns in the file @var{file}. @xref{exclude}.
  1893. @opindex exclude-caches, summary
  1894. @item --exclude-caches
  1895. Automatically excludes all directories
  1896. containing a cache directory tag. @xref{exclude}.
  1897. @opindex file, summary
  1898. @item --file=@var{archive}
  1899. @itemx -f @var{archive}
  1900. @command{tar} will use the file @var{archive} as the @command{tar} archive it
  1901. performs operations on, rather than @command{tar}'s compilation dependent
  1902. default. @xref{file tutorial}.
  1903. @opindex files-from, summary
  1904. @item --files-from=@var{file}
  1905. @itemx -T @var{file}
  1906. @command{tar} will use the contents of @var{file} as a list of archive members
  1907. or files to operate on, in addition to those specified on the
  1908. command-line. @xref{files}.
  1909. @opindex force-local, summary
  1910. @item --force-local
  1911. Forces @command{tar} to interpret the filename given to @option{--file}
  1912. as a local file, even if it looks like a remote tape drive name.
  1913. @xref{local and remote archives}.
  1914. @opindex format, summary
  1915. @item --format=@var{format}
  1916. Selects output archive format. @var{Format} may be one of the
  1917. following:
  1918. @table @samp
  1919. @item v7
  1920. Creates an archive that is compatible with Unix V7 @command{tar}.
  1921. @item oldgnu
  1922. Creates an archive that is compatible with GNU @command{tar} version
  1923. 1.12 or earlier.
  1924. @item gnu
  1925. Creates archive in GNU tar 1.13 format. Basically it is the same as
  1926. @samp{oldgnu} with the only difference in the way it handles long
  1927. numeric fields.
  1928. @item ustar
  1929. Creates a @acronym{POSIX.1-1988} compatible archive.
  1930. @item posix
  1931. Creates a @acronym{POSIX.1-2001 archive}.
  1932. @end table
  1933. @xref{Formats}, for a detailed discussion of these formats.
  1934. @opindex group, summary
  1935. @item --group=@var{group}
  1936. Files added to the @command{tar} archive will have a group id of @var{group},
  1937. rather than the group from the source file. @var{group} is first decoded
  1938. as a group symbolic name, but if this interpretation fails, it has to be
  1939. a decimal numeric group ID. @FIXME-xref{}
  1940. Also see the comments for the @option{--owner=@var{user}} option.
  1941. @opindex gzip, summary
  1942. @opindex gunzip, summary
  1943. @opindex ungzip, summary
  1944. @item --gzip
  1945. @itemx --gunzip
  1946. @itemx --ungzip
  1947. @itemx -z
  1948. This option tells @command{tar} to read or write archives through
  1949. @command{gzip}, allowing @command{tar} to directly operate on several
  1950. kinds of compressed archives transparently. @xref{gzip}.
  1951. @opindex help, summary
  1952. @item --help
  1953. @command{tar} will print out a short message summarizing the operations and
  1954. options to @command{tar} and exit. @xref{help}.
  1955. @opindex ignore-case, summary
  1956. @item --ignore-case
  1957. Ignore case when matching member or file names with
  1958. patterns. @xref{controlling pattern-matching}.
  1959. @opindex ignore-command-error, summary
  1960. @item --ignore-command-error
  1961. Ignore exit codes of subprocesses. @xref{Writing to an External Program}.
  1962. @opindex ignore-failed-read, summary
  1963. @item --ignore-failed-read
  1964. Do not exit unsuccessfully merely because an unreadable file was encountered.
  1965. @xref{Reading}.
  1966. @opindex ignore-zeros, summary
  1967. @item --ignore-zeros
  1968. @itemx -i
  1969. With this option, @command{tar} will ignore zeroed blocks in the
  1970. archive, which normally signals EOF. @xref{Reading}.
  1971. @opindex incremental, summary
  1972. @item --incremental
  1973. @itemx -G
  1974. Used to inform @command{tar} that it is working with an old
  1975. @acronym{GNU}-format incremental backup archive. It is intended
  1976. primarily for backwards compatibility only. @xref{Incremental Dumps},
  1977. for a detailed discussion of incremental archives.
  1978. @opindex index-file, summary
  1979. @item --index-file=@var{file}
  1980. Send verbose output to @var{file} instead of to standard output.
  1981. @opindex info-script, summary
  1982. @opindex new-volume-script, summary
  1983. @item --info-script=@var{script-file}
  1984. @itemx --new-volume-script=@var{script-file}
  1985. @itemx -F @var{script-file}
  1986. When @command{tar} is performing multi-tape backups, @var{script-file} is run
  1987. at the end of each tape. If @var{script-file} exits with nonzero status,
  1988. @command{tar} fails immediately. @xref{info-script}, for a detailed
  1989. discussion of @var{script-file}.
  1990. @opindex interactive, summary
  1991. @item --interactive
  1992. @itemx --confirmation
  1993. @itemx -w
  1994. Specifies that @command{tar} should ask the user for confirmation before
  1995. performing potentially destructive options, such as overwriting files.
  1996. @xref{interactive}.
  1997. @opindex keep-newer-files, summary
  1998. @item --keep-newer-files
  1999. Do not replace existing files that are newer than their archive copies
  2000. when extracting files from an archive.
  2001. @opindex keep-old-files, summary
  2002. @item --keep-old-files
  2003. @itemx -k
  2004. Do not overwrite existing files when extracting files from an archive.
  2005. @xref{Keep Old Files}.
  2006. @opindex label, summary
  2007. @item --label=@var{name}
  2008. @itemx -V @var{name}
  2009. When creating an archive, instructs @command{tar} to write @var{name}
  2010. as a name record in the archive. When extracting or listing archives,
  2011. @command{tar} will only operate on archives that have a label matching
  2012. the pattern specified in @var{name}. @xref{Tape Files}.
  2013. @opindex listed-incremental, summary
  2014. @item --listed-incremental=@var{snapshot-file}
  2015. @itemx -g @var{snapshot-file}
  2016. During a @option{--create} operation, specifies that the archive that
  2017. @command{tar} creates is a new @acronym{GNU}-format incremental
  2018. backup, using @var{snapshot-file} to determine which files to backup.
  2019. With other operations, informs @command{tar} that the archive is in
  2020. incremental format. @xref{Incremental Dumps}.
  2021. @opindex mode, summary
  2022. @item --mode=@var{permissions}
  2023. When adding files to an archive, @command{tar} will use
  2024. @var{permissions} for the archive members, rather than the permissions
  2025. from the files. The program @command{chmod} and this @command{tar}
  2026. option share the same syntax for what @var{permissions} might be.
  2027. @xref{File permissions, Permissions, File permissions, fileutils,
  2028. @acronym{GNU} file utilities}. This reference also has useful
  2029. information for those not being overly familiar with the Unix
  2030. permission system.
  2031. Of course, @var{permissions} might be plainly specified as an octal number.
  2032. However, by using generic symbolic modifications to mode bits, this allows
  2033. more flexibility. For example, the value @samp{a+rw} adds read and write
  2034. permissions for everybody, while retaining executable bits on directories
  2035. or on any other file already marked as executable.
  2036. @opindex multi-volume, summary
  2037. @item --multi-volume
  2038. @itemx -M
  2039. Informs @command{tar} that it should create or otherwise operate on a
  2040. multi-volume @command{tar} archive. @xref{Using Multiple Tapes}.
  2041. @opindex new-volume-script, summary
  2042. @item --new-volume-script
  2043. (see --info-script)
  2044. @opindex seek, summary
  2045. @item --seek
  2046. @itemx -n
  2047. Assume that the archive media supports seeks to arbitrary
  2048. locations. Usually @command{tar} determines automatically whether
  2049. the archive can be seeked or not. This option is intended for use
  2050. in cases when such recognition fails.
  2051. @opindex newer, summary
  2052. @item --newer=@var{date}
  2053. @itemx --after-date=@var{date}
  2054. @itemx -N
  2055. When creating an archive, @command{tar} will only add files that have changed
  2056. since @var{date}. If @var{date} begins with @samp{/} or @samp{.}, it
  2057. is taken to be the name of a file whose data modification time specifies
  2058. the date. @xref{after}.
  2059. @opindex newer-mtime, summary
  2060. @item --newer-mtime=@var{date}
  2061. Like @option{--newer}, but add only files whose
  2062. contents have changed (as opposed to just @option{--newer}, which will
  2063. also back up files for which any status information has changed).
  2064. @opindex no-anchored, summary
  2065. @item --no-anchored
  2066. An exclude pattern can match any subsequence of the name's components.
  2067. @xref{controlling pattern-matching}.
  2068. @opindex no-delay-directory-restore, summary
  2069. @item --no-delay-directory-restore
  2070. Setting modification times and permissions of extracted
  2071. directories when all files from this directory has been
  2072. extracted. This is the default. @xref{Directory Modification Times and Permissions}.
  2073. @opindex no-ignore-case, summary
  2074. @item --no-ignore-case
  2075. Use case-sensitive matching.
  2076. @xref{controlling pattern-matching}.
  2077. @opindex no-ignore-command-error, summary
  2078. @item --no-ignore-command-error
  2079. Print warnings about subprocesses terminated with a non-zero exit
  2080. code. @xref{Writing to an External Program}.
  2081. @opindex no-quote-chars, summary
  2082. @item --no-quote-chars=@var{string}
  2083. Remove characters listed in @var{string} from the list of quoted
  2084. characters set by the previous @option{--quote-chars} option
  2085. (@pxref{quoting styles}).
  2086. @opindex no-recursion, summary
  2087. @item --no-recursion
  2088. With this option, @command{tar} will not recurse into directories.
  2089. @xref{recurse}.
  2090. @opindex no-same-owner, summary
  2091. @item --no-same-owner
  2092. @itemx -o
  2093. When extracting an archive, do not attempt to preserve the owner
  2094. specified in the @command{tar} archive. This the default behavior
  2095. for ordinary users.
  2096. @opindex no-same-permissions, summary
  2097. @item --no-same-permissions
  2098. When extracting an archive, subtract the user's umask from files from
  2099. the permissions specified in the archive. This is the default behavior
  2100. for ordinary users.
  2101. @opindex no-wildcards, summary
  2102. @item --no-wildcards
  2103. Do not use wildcards.
  2104. @xref{controlling pattern-matching}.
  2105. @opindex no-wildcards-match-slash, summary
  2106. @item --no-wildcards-match-slash
  2107. Wildcards do not match @samp{/}.
  2108. @xref{controlling pattern-matching}.
  2109. @opindex null, summary
  2110. @item --null
  2111. When @command{tar} is using the @option{--files-from} option, this option
  2112. instructs @command{tar} to expect filenames terminated with @option{NUL}, so
  2113. @command{tar} can correctly work with file names that contain newlines.
  2114. @xref{nul}.
  2115. @opindex numeric-owner, summary
  2116. @item --numeric-owner
  2117. This option will notify @command{tar} that it should use numeric user
  2118. and group IDs when creating a @command{tar} file, rather than names.
  2119. @xref{Attributes}.
  2120. @item -o
  2121. When extracting files, this option is a synonym for
  2122. @option{--no-same-owner}, i.e. it prevents @command{tar} from
  2123. restoring ownership of files being extracted.
  2124. When creating an archive, @option{-o} is a synonym for
  2125. @option{--old-archive}. This behavior is for compatibility
  2126. with previous versions of @GNUTAR{}, and will be
  2127. removed in the future releases.
  2128. @xref{Changes}, for more information.
  2129. @opindex occurrence, summary
  2130. @item --occurrence[=@var{number}]
  2131. This option can be used in conjunction with one of the subcommands
  2132. @option{--delete}, @option{--diff}, @option{--extract} or
  2133. @option{--list} when a list of files is given either on the command
  2134. line or via @option{-T} option.
  2135. This option instructs @command{tar} to process only the @var{number}th
  2136. occurrence of each named file. @var{Number} defaults to 1, so
  2137. @smallexample
  2138. tar -x -f archive.tar --occurrence filename
  2139. @end smallexample
  2140. @noindent
  2141. will extract the first occurrence of @file{filename} from @file{archive.tar}
  2142. and will terminate without scanning to the end of the archive.
  2143. @opindex old-archive, summary
  2144. @item --old-archive
  2145. Synonym for @option{--format=v7}.
  2146. @opindex one-file-system, summary
  2147. @item --one-file-system
  2148. Used when creating an archive. Prevents @command{tar} from recursing into
  2149. directories that are on different file systems from the current
  2150. directory @footnote{Earlier versions of @GNUTAR{} understood @option{-l} as a
  2151. synonym for @option{--one-file-system}. This has changed in version
  2152. 1.15.91. @xref{Changes}, for more information.}.
  2153. @opindex overwrite, summary
  2154. @item --overwrite
  2155. Overwrite existing files and directory metadata when extracting files
  2156. from an archive. @xref{Overwrite Old Files}.
  2157. @opindex overwrite-dir, summary
  2158. @item --overwrite-dir
  2159. Overwrite the metadata of existing directories when extracting files
  2160. from an archive. @xref{Overwrite Old Files}.
  2161. @opindex owner, summary
  2162. @item --owner=@var{user}
  2163. Specifies that @command{tar} should use @var{user} as the owner of members
  2164. when creating archives, instead of the user associated with the source
  2165. file. @var{user} is first decoded as a user symbolic name, but if
  2166. this interpretation fails, it has to be a decimal numeric user ID.
  2167. @FIXME-xref{}
  2168. There is no value indicating a missing number, and @samp{0} usually means
  2169. @code{root}. Some people like to force @samp{0} as the value to offer in
  2170. their distributions for the owner of files, because the @code{root} user is
  2171. anonymous anyway, so that might as well be the owner of anonymous archives.
  2172. This option does not affect extraction from archives.
  2173. @opindex transform, summary
  2174. @item --transform=@var{sed-expr}
  2175. Transform file or member names using @command{sed} replacement expression
  2176. @var{sed-expr}. For example,
  2177. @smallexample
  2178. $ @kbd{tar cf archive.tar --transform 's,^\./,usr/,' .}
  2179. @end smallexample
  2180. @noindent
  2181. will add to @file{archive} files from the current working directory,
  2182. replacing initial @samp{./} prefix with @samp{usr/}. For the detailed
  2183. discussion, @xref{transform}.
  2184. To see transformed member names in verbose listings, use
  2185. @option{--show-transformed-names} option
  2186. (@pxref{show-transformed-names}).
  2187. @opindex quote-chars, summary
  2188. @item --quote-chars=@var{string}
  2189. Always quote characters from @var{string}, even if the selected
  2190. quoting style would not quote them (@pxref{quoting styles}).
  2191. @opindex quoting-style, summary
  2192. @item --quoting-style=@var{style}
  2193. Set quoting style to use when printing member and file names
  2194. (@pxref{quoting styles}). Valid @var{style} values are:
  2195. @code{literal}, @code{shell}, @code{shell-always}, @code{c},
  2196. @code{escape}, @code{locale}, and @code{clocale}. Default quoting
  2197. style is @code{escape}, unless overridden while configuring the
  2198. package.
  2199. @opindex pax-option, summary
  2200. @item --pax-option=@var{keyword-list}
  2201. @FIXME{Such a detailed description does not belong there, move it elsewhere.}
  2202. This option is meaningful only with @acronym{POSIX.1-2001} archives
  2203. (@pxref{posix}). It modifies the way @command{tar} handles the
  2204. extended header keywords. @var{Keyword-list} is a comma-separated
  2205. list of keyword options, each keyword option taking one of
  2206. the following forms:
  2207. @table @asis
  2208. @item delete=@var{pattern}
  2209. When used with one of archive-creation commands,
  2210. this option instructs @command{tar} to omit from extended header records
  2211. that it produces any keywords matching the string @var{pattern}.
  2212. When used in extract or list mode, this option instructs tar
  2213. to ignore any keywords matching the given @var{pattern} in the extended
  2214. header records. In both cases, matching is performed using the pattern
  2215. matching notation described in @acronym{POSIX 1003.2}, 3.13
  2216. (See @cite{glob(7)}). For example:
  2217. @smallexample
  2218. --pax-option delete=security.*
  2219. @end smallexample
  2220. would suppress security-related information.
  2221. @item exthdr.name=@var{string}
  2222. This keyword allows user control over the name that is written into the
  2223. ustar header blocks for the extended headers. The name is obtained
  2224. from @var{string} after making the following substitutions:
  2225. @multitable @columnfractions .30 .70
  2226. @headitem Meta-character @tab Replaced By
  2227. @item %d @tab The directory name of the file, equivalent to the
  2228. result of the @command{dirname} utility on the translated pathname.
  2229. @item %f @tab The filename of the file, equivalent to the result
  2230. of the @command{basename} utility on the translated pathname.
  2231. @item %p @tab The process ID of the @command{tar} process.
  2232. @item %% @tab A @samp{%} character.
  2233. @end multitable
  2234. Any other @samp{%} characters in @var{string} produce undefined
  2235. results.
  2236. If no option @samp{exthdr.name=string} is specified, @command{tar}
  2237. will use the following default value:
  2238. @smallexample
  2239. %d/PaxHeaders.%p/%f
  2240. @end smallexample
  2241. @item globexthdr.name=@var{string}
  2242. This keyword allows user control over the name that is written into
  2243. the ustar header blocks for global extended header records. The name
  2244. is obtained from the contents of @var{string}, after making
  2245. the following substitutions:
  2246. @multitable @columnfractions .30 .70
  2247. @headitem Meta-character @tab Replaced By
  2248. @item %n @tab An integer that represents the
  2249. sequence number of the global extended header record in the archive,
  2250. starting at 1.
  2251. @item %p @tab The process ID of the @command{tar} process.
  2252. @item %% @tab A @samp{%} character.
  2253. @end multitable
  2254. Any other @samp{%} characters in @var{string} produce undefined results.
  2255. If no option @samp{globexthdr.name=string} is specified, @command{tar}
  2256. will use the following default value:
  2257. @smallexample
  2258. $TMPDIR/GlobalHead.%p.%n
  2259. @end smallexample
  2260. @noindent
  2261. where @samp{$TMPDIR} represents the value of the @var{TMPDIR}
  2262. environment variable. If @var{TMPDIR} is not set, @command{tar}
  2263. uses @samp{/tmp}.
  2264. @item @var{keyword}=@var{value}
  2265. When used with one of archive-creation commands, these keyword/value pairs
  2266. will be included at the beginning of the archive in a global extended
  2267. header record. When used with one of archive-reading commands,
  2268. @command{tar} will behave as if it has encountered these keyword/value
  2269. pairs at the beginning of the archive in a global extended header
  2270. record.
  2271. @item @var{keyword}:=@var{value}
  2272. When used with one of archive-creation commands, these keyword/value pairs
  2273. will be included as records at the beginning of an extended header for
  2274. each file. This is effectively equivalent to @var{keyword}=@var{value}
  2275. form except that it creates no global extended header records.
  2276. When used with one of archive-reading commands, @command{tar} will
  2277. behave as if these keyword/value pairs were included as records at the
  2278. end of each extended header; thus, they will override any global or
  2279. file-specific extended header record keywords of the same names.
  2280. For example, in the command:
  2281. @smallexample
  2282. tar --format=posix --create \
  2283. --file archive --pax-option gname:=user .
  2284. @end smallexample
  2285. the group name will be forced to a new value for all files
  2286. stored in the archive.
  2287. @end table
  2288. @opindex portability, summary
  2289. @item --portability
  2290. @itemx --old-archive
  2291. Synonym for @option{--format=v7}.
  2292. @opindex posix, summary
  2293. @item --posix
  2294. Same as @option{--format=posix}.
  2295. @opindex preserve, summary
  2296. @item --preserve
  2297. Synonymous with specifying both @option{--preserve-permissions} and
  2298. @option{--same-order}. @xref{Setting Access Permissions}.
  2299. @opindex preserve-order, summary
  2300. @item --preserve-order
  2301. (See @option{--same-order}; @pxref{Reading}.)
  2302. @opindex preserve-permissions, summary
  2303. @opindex same-permissions, summary
  2304. @item --preserve-permissions
  2305. @itemx --same-permissions
  2306. @itemx -p
  2307. When @command{tar} is extracting an archive, it normally subtracts the
  2308. users' umask from the permissions specified in the archive and uses
  2309. that number as the permissions to create the destination file.
  2310. Specifying this option instructs @command{tar} that it should use the
  2311. permissions directly from the archive. @xref{Setting Access Permissions}.
  2312. @opindex read-full-records, summary
  2313. @item --read-full-records
  2314. @itemx -B
  2315. Specifies that @command{tar} should reblock its input, for reading
  2316. from pipes on systems with buggy implementations. @xref{Reading}.
  2317. @opindex record-size, summary
  2318. @item --record-size=@var{size}
  2319. Instructs @command{tar} to use @var{size} bytes per record when accessing the
  2320. archive. @xref{Blocking Factor}.
  2321. @opindex recursion, summary
  2322. @item --recursion
  2323. With this option, @command{tar} recurses into directories.
  2324. @xref{recurse}.
  2325. @opindex recursive-unlink, summary
  2326. @item --recursive-unlink
  2327. Remove existing
  2328. directory hierarchies before extracting directories of the same name
  2329. from the archive. @xref{Recursive Unlink}.
  2330. @opindex remove-files, summary
  2331. @item --remove-files
  2332. Directs @command{tar} to remove the source file from the file system after
  2333. appending it to an archive. @xref{remove files}.
  2334. @opindex restrict, summary
  2335. @item --restrict
  2336. Disable use of some potentially harmful @command{tar} options.
  2337. Currently this option disables shell invocaton from multi-volume menu
  2338. (@pxref{Using Multiple Tapes}).
  2339. @opindex rmt-command, summary
  2340. @item --rmt-command=@var{cmd}
  2341. Notifies @command{tar} that it should use @var{cmd} instead of
  2342. the default @file{/usr/libexec/rmt} (@pxref{Remote Tape Server}).
  2343. @opindex rsh-command, summary
  2344. @item --rsh-command=@var{cmd}
  2345. Notifies @command{tar} that is should use @var{cmd} to communicate with remote
  2346. devices. @xref{Device}.
  2347. @opindex same-order, summary
  2348. @item --same-order
  2349. @itemx --preserve-order
  2350. @itemx -s
  2351. This option is an optimization for @command{tar} when running on machines with
  2352. small amounts of memory. It informs @command{tar} that the list of file
  2353. arguments has already been sorted to match the order of files in the
  2354. archive. @xref{Reading}.
  2355. @opindex same-owner, summary
  2356. @item --same-owner
  2357. When extracting an archive, @command{tar} will attempt to preserve the owner
  2358. specified in the @command{tar} archive with this option present.
  2359. This is the default behavior for the superuser; this option has an
  2360. effect only for ordinary users. @xref{Attributes}.
  2361. @opindex same-permissions, summary
  2362. @item --same-permissions
  2363. (See @option{--preserve-permissions}; @pxref{Setting Access Permissions}.)
  2364. @opindex show-defaults, summary
  2365. @item --show-defaults
  2366. Displays the default options used by @command{tar} and exits
  2367. successfully. This option is intended for use in shell scripts.
  2368. Here is an example of what you can see using this option:
  2369. @smallexample
  2370. $ tar --show-defaults
  2371. --format=gnu -f- -b20 --quoting-style=escape \
  2372. --rmt-command=/usr/libexec/rmt --rsh-command=/usr/bin/rsh
  2373. @end smallexample
  2374. @opindex show-omitted-dirs, summary
  2375. @item --show-omitted-dirs
  2376. Instructs @command{tar} to mention directories its skipping over when
  2377. operating on a @command{tar} archive. @xref{show-omitted-dirs}.
  2378. @opindex show-transformed-names, summary
  2379. @opindex show-stored-names, summary
  2380. @item --show-transformed-names
  2381. @itemx --show-stored-names
  2382. Display file or member names after applying any transformations
  2383. (@pxref{transform}). In particular, when used in conjunction with one of
  2384. archive creation operations it instructs tar to list the member names
  2385. stored in the archive, as opposed to the actual file
  2386. names. @xref{listing member and file names}.
  2387. @opindex sparse, summary
  2388. @item --sparse
  2389. @itemx -S
  2390. Invokes a @acronym{GNU} extension when adding files to an archive that handles
  2391. sparse files efficiently. @xref{sparse}.
  2392. @opindex starting-file, summary
  2393. @item --starting-file=@var{name}
  2394. @itemx -K @var{name}
  2395. This option affects extraction only; @command{tar} will skip extracting
  2396. files in the archive until it finds one that matches @var{name}.
  2397. @xref{Scarce}.
  2398. @opindex strip-components, summary
  2399. @item --strip-components=@var{number}
  2400. Strip given @var{number} of leading components from file names before
  2401. extraction.@footnote{This option was called @option{--strip-path} in
  2402. version 1.14.} For example, if archive @file{archive.tar} contained
  2403. @file{/some/file/name}, then running
  2404. @smallexample
  2405. tar --extract --file archive.tar --strip-components=2
  2406. @end smallexample
  2407. @noindent
  2408. would extract this file to file @file{name}.
  2409. @opindex suffix, summary
  2410. @item --suffix=@var{suffix}
  2411. Alters the suffix @command{tar} uses when backing up files from the default
  2412. @samp{~}. @xref{backup}.
  2413. @opindex tape-length, summary
  2414. @item --tape-length=@var{num}
  2415. @itemx -L @var{num}
  2416. Specifies the length of tapes that @command{tar} is writing as being
  2417. @w{@var{num} x 1024} bytes long. @xref{Using Multiple Tapes}.
  2418. @opindex test-label, summary
  2419. @item --test-label
  2420. Reads the volume label. If an argument is specified, test whether it
  2421. matches the volume label. @xref{--test-label option}.
  2422. @opindex to-command, summary
  2423. @item --to-command=@var{command}
  2424. During extraction @command{tar} will pipe extracted files to the
  2425. standard input of @var{command}. @xref{Writing to an External Program}.
  2426. @opindex to-stdout, summary
  2427. @item --to-stdout
  2428. @itemx -O
  2429. During extraction, @command{tar} will extract files to stdout rather
  2430. than to the file system. @xref{Writing to Standard Output}.
  2431. @opindex totals, summary
  2432. @item --totals
  2433. Displays the total number of bytes written after creating an archive.
  2434. @xref{verbose}.
  2435. @opindex touch, summary
  2436. @item --touch
  2437. @itemx -m
  2438. Sets the data modification time of extracted files to the extraction time,
  2439. rather than the data modification time stored in the archive.
  2440. @xref{Data Modification Times}.
  2441. @opindex uncompress, summary
  2442. @item --uncompress
  2443. (See @option{--compress}. @pxref{gzip})
  2444. @opindex ungzip, summary
  2445. @item --ungzip
  2446. (See @option{--gzip}. @pxref{gzip})
  2447. @opindex unlink-first, summary
  2448. @item --unlink-first
  2449. @itemx -U
  2450. Directs @command{tar} to remove the corresponding file from the file
  2451. system before extracting it from the archive. @xref{Unlink First}.
  2452. @opindex use-compress-program, summary
  2453. @item --use-compress-program=@var{prog}
  2454. Instructs @command{tar} to access the archive through @var{prog}, which is
  2455. presumed to be a compression program of some sort. @xref{gzip}.
  2456. @opindex utc, summary
  2457. @item --utc
  2458. Display file modification dates in @acronym{UTC}. This option implies
  2459. @option{--verbose}.
  2460. @opindex verbose, summary
  2461. @item --verbose
  2462. @itemx -v
  2463. Specifies that @command{tar} should be more verbose about the operations its
  2464. performing. This option can be specified multiple times for some
  2465. operations to increase the amount of information displayed.
  2466. @xref{verbose}.
  2467. @opindex verify, summary
  2468. @item --verify
  2469. @itemx -W
  2470. Verifies that the archive was correctly written when creating an
  2471. archive. @xref{verify}.
  2472. @opindex version, summary
  2473. @item --version
  2474. Print information about the program's name, version, origin and legal
  2475. status, all on standard output, and then exit successfully.
  2476. @xref{help}.
  2477. @opindex volno-file, summary
  2478. @item --volno-file=@var{file}
  2479. Used in conjunction with @option{--multi-volume}. @command{tar} will keep track
  2480. of which volume of a multi-volume archive its working in @var{file}.
  2481. @xref{volno-file}.
  2482. @opindex wildcards, summary
  2483. @item --wildcards
  2484. Use wildcards when matching member names with patterns.
  2485. @xref{controlling pattern-matching}.
  2486. @opindex wildcards-match-slash, summary
  2487. @item --wildcards-match-slash
  2488. Wildcards match @samp{/}.
  2489. @xref{controlling pattern-matching}.
  2490. @end table
  2491. @node Short Option Summary
  2492. @subsection Short Options Cross Reference
  2493. Here is an alphabetized list of all of the short option forms, matching
  2494. them with the equivalent long option.
  2495. @table @option
  2496. @item -A
  2497. @option{--concatenate}
  2498. @item -B
  2499. @option{--read-full-records}
  2500. @item -C
  2501. @option{--directory}
  2502. @item -F
  2503. @option{--info-script}
  2504. @item -G
  2505. @option{--incremental}
  2506. @item -K
  2507. @option{--starting-file}
  2508. @item -L
  2509. @option{--tape-length}
  2510. @item -M
  2511. @option{--multi-volume}
  2512. @item -N
  2513. @option{--newer}
  2514. @item -O
  2515. @option{--to-stdout}
  2516. @item -P
  2517. @option{--absolute-names}
  2518. @item -R
  2519. @option{--block-number}
  2520. @item -S
  2521. @option{--sparse}
  2522. @item -T
  2523. @option{--files-from}
  2524. @item -U
  2525. @option{--unlink-first}
  2526. @item -V
  2527. @option{--label}
  2528. @item -W
  2529. @option{--verify}
  2530. @item -X
  2531. @option{--exclude-from}
  2532. @item -Z
  2533. @option{--compress}
  2534. @item -b
  2535. @option{--blocking-factor}
  2536. @item -c
  2537. @option{--create}
  2538. @item -d
  2539. @option{--compare}
  2540. @item -f
  2541. @option{--file}
  2542. @item -g
  2543. @option{--listed-incremental}
  2544. @item -h
  2545. @option{--dereference}
  2546. @item -i
  2547. @option{--ignore-zeros}
  2548. @item -j
  2549. @option{--bzip2}
  2550. @item -k
  2551. @option{--keep-old-files}
  2552. @item -l
  2553. @option{--one-file-system}. Use of this short option is deprecated. It
  2554. is retained for compatibility with the earlier versions of GNU
  2555. @command{tar}, and will be changed in future releases.
  2556. @xref{Changes}, for more information.
  2557. @item -m
  2558. @option{--touch}
  2559. @item -o
  2560. When creating --- @option{--no-same-owner}, when extracting ---
  2561. @option{--portability}.
  2562. The later usage is deprecated. It is retained for compatibility with
  2563. the earlier versions of @GNUTAR{}. In the future releases
  2564. @option{-o} will be equivalent to @option{--no-same-owner} only.
  2565. @item -p
  2566. @option{--preserve-permissions}
  2567. @item -r
  2568. @option{--append}
  2569. @item -s
  2570. @option{--same-order}
  2571. @item -t
  2572. @option{--list}
  2573. @item -u
  2574. @option{--update}
  2575. @item -v
  2576. @option{--verbose}
  2577. @item -w
  2578. @option{--interactive}
  2579. @item -x
  2580. @option{--extract}
  2581. @item -z
  2582. @option{--gzip}
  2583. @end table
  2584. @node help
  2585. @section @GNUTAR{} documentation
  2586. @cindex Getting program version number
  2587. @opindex version
  2588. @cindex Version of the @command{tar} program
  2589. Being careful, the first thing is really checking that you are using
  2590. @GNUTAR{}, indeed. The @option{--version} option
  2591. causes @command{tar} to print information about its name, version,
  2592. origin and legal status, all on standard output, and then exit
  2593. successfully. For example, @w{@samp{tar --version}} might print:
  2594. @smallexample
  2595. tar (GNU tar) 1.15.2
  2596. Copyright (C) 2006 Free Software Foundation, Inc.
  2597. This is free software. You may redistribute copies of it under the terms of
  2598. the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
  2599. There is NO WARRANTY, to the extent permitted by law.
  2600. Written by John Gilmore and Jay Fenlason.
  2601. @end smallexample
  2602. @noindent
  2603. The first occurrence of @samp{tar} in the result above is the program
  2604. name in the package (for example, @command{rmt} is another program),
  2605. while the second occurrence of @samp{tar} is the name of the package
  2606. itself, containing possibly many programs. The package is currently
  2607. named @samp{tar}, after the name of the main program it
  2608. contains@footnote{There are plans to merge the @command{cpio} and
  2609. @command{tar} packages into a single one which would be called
  2610. @code{paxutils}. So, who knows if, one of this days, the
  2611. @option{--version} would not output @w{@samp{tar (@acronym{GNU}
  2612. paxutils) 3.2}}}.
  2613. @cindex Obtaining help
  2614. @cindex Listing all @command{tar} options
  2615. @opindex help, introduction
  2616. Another thing you might want to do is checking the spelling or meaning
  2617. of some particular @command{tar} option, without resorting to this
  2618. manual, for once you have carefully read it. @GNUTAR{}
  2619. has a short help feature, triggerable through the
  2620. @option{--help} option. By using this option, @command{tar} will
  2621. print a usage message listing all available options on standard
  2622. output, then exit successfully, without doing anything else and
  2623. ignoring all other options. Even if this is only a brief summary, it
  2624. may be several screens long. So, if you are not using some kind of
  2625. scrollable window, you might prefer to use something like:
  2626. @smallexample
  2627. $ @kbd{tar --help | less}
  2628. @end smallexample
  2629. @noindent
  2630. presuming, here, that you like using @command{less} for a pager. Other
  2631. popular pagers are @command{more} and @command{pg}. If you know about some
  2632. @var{keyword} which interests you and do not want to read all the
  2633. @option{--help} output, another common idiom is doing:
  2634. @smallexample
  2635. tar --help | grep @var{keyword}
  2636. @end smallexample
  2637. @noindent
  2638. for getting only the pertinent lines. Notice, however, that some
  2639. @command{tar} options have long description lines and the above
  2640. command will list only the first of them.
  2641. The exact look of the option summary displayed by @kbd{tar --help} is
  2642. configurable. @xref{Configuring Help Summary}, for a detailed description.
  2643. @opindex usage
  2644. If you only wish to check the spelling of an option, running @kbd{tar
  2645. --usage} may be a better choice. This will display a terse list of
  2646. @command{tar} option without accompanying explanations.
  2647. The short help output is quite succinct, and you might have to get
  2648. back to the full documentation for precise points. If you are reading
  2649. this paragraph, you already have the @command{tar} manual in some
  2650. form. This manual is available in a variety of forms from
  2651. @url{http://www.gnu.org/software/tar/manual}. It may printed out of the @GNUTAR{}
  2652. distribution, provided you have @TeX{} already installed somewhere,
  2653. and a laser printer around. Just configure the distribution, execute
  2654. the command @w{@samp{make dvi}}, then print @file{doc/tar.dvi} the
  2655. usual way (contact your local guru to know how). If @GNUTAR{}
  2656. has been conveniently installed at your place, this
  2657. manual is also available in interactive, hypertextual form as an Info
  2658. file. Just call @w{@samp{info tar}} or, if you do not have the
  2659. @command{info} program handy, use the Info reader provided within
  2660. @acronym{GNU} Emacs, calling @samp{tar} from the main Info menu.
  2661. There is currently no @code{man} page for @GNUTAR{}.
  2662. If you observe such a @code{man} page on the system you are running,
  2663. either it does not belong to @GNUTAR{}, or it has not
  2664. been produced by @acronym{GNU}. Some package maintainers convert
  2665. @kbd{tar --help} output to a man page, using @command{help2man}. In
  2666. any case, please bear in mind that the authoritative source of
  2667. information about @GNUTAR{} is this Texinfo documentation.
  2668. @node defaults
  2669. @section Obtaining @GNUTAR{} default values
  2670. @opindex show-defaults
  2671. @GNUTAR{} has some predefined defaults that are used when you do not
  2672. explicitely specify another values. To obtain a list of such
  2673. defaults, use @option{--show-defaults} option. This will output the
  2674. values in the form of @command{tar} command line options:
  2675. @smallexample
  2676. @group
  2677. @kbd{tar --show-defaults}
  2678. --format=gnu -f- -b20 --rmt-command=/etc/rmt --rsh-command=/usr/bin/rsh
  2679. @end group
  2680. @end smallexample
  2681. @noindent
  2682. The above output shows that this version of @GNUTAR{} defaults to
  2683. using @samp{gnu} archive format (@pxref{Formats}), it uses standard
  2684. output as the archive, if no @option{--file} option has been given
  2685. (@pxref{file tutorial}), the default blocking factor is 20
  2686. (@pxref{Blocking Factor}). It also shows the default locations where
  2687. @command{tar} will look for @command{rmt} and @command{rsh} binaries.
  2688. @node verbose
  2689. @section Checking @command{tar} progress
  2690. Typically, @command{tar} performs most operations without reporting any
  2691. information to the user except error messages. When using @command{tar}
  2692. with many options, particularly ones with complicated or
  2693. difficult-to-predict behavior, it is possible to make serious mistakes.
  2694. @command{tar} provides several options that make observing @command{tar}
  2695. easier. These options cause @command{tar} to print information as it
  2696. progresses in its job, and you might want to use them just for being
  2697. more careful about what is going on, or merely for entertaining
  2698. yourself. If you have encountered a problem when operating on an
  2699. archive, however, you may need more information than just an error
  2700. message in order to solve the problem. The following options can be
  2701. helpful diagnostic tools.
  2702. @cindex Verbose operation
  2703. @opindex verbose
  2704. Normally, the @option{--list} (@option{-t}) command to list an archive
  2705. prints just the file names (one per line) and the other commands are
  2706. silent. When used with most operations, the @option{--verbose}
  2707. (@option{-v}) option causes @command{tar} to print the name of each
  2708. file or archive member as it is processed. This and the other options
  2709. which make @command{tar} print status information can be useful in
  2710. monitoring @command{tar}.
  2711. With @option{--create} or @option{--extract}, @option{--verbose} used
  2712. once just prints the names of the files or members as they are processed.
  2713. Using it twice causes @command{tar} to print a longer listing
  2714. (reminiscent of @samp{ls -l}) for each member. Since @option{--list}
  2715. already prints the names of the members, @option{--verbose} used once
  2716. with @option{--list} causes @command{tar} to print an @samp{ls -l}
  2717. type listing of the files in the archive. The following examples both
  2718. extract members with long list output:
  2719. @smallexample
  2720. $ @kbd{tar --extract --file=archive.tar --verbose --verbose}
  2721. $ @kbd{tar xvvf archive.tar}
  2722. @end smallexample
  2723. Verbose output appears on the standard output except when an archive is
  2724. being written to the standard output, as with @samp{tar --create
  2725. --file=- --verbose} (@samp{tar cfv -}, or even @samp{tar cv}---if the
  2726. installer let standard output be the default archive). In that case
  2727. @command{tar} writes verbose output to the standard error stream.
  2728. If @option{--index-file=@var{file}} is specified, @command{tar} sends
  2729. verbose output to @var{file} rather than to standard output or standard
  2730. error.
  2731. @cindex Obtaining total status information
  2732. @opindex totals
  2733. The @option{--totals} option---which is only meaningful when used with
  2734. @option{--create} (@option{-c})---causes @command{tar} to print the total
  2735. amount written to the archive, after it has been fully created.
  2736. @anchor{Progress information}
  2737. @cindex Progress information
  2738. @opindex checkpoint
  2739. The @option{--checkpoint} option prints an occasional message
  2740. as @command{tar} reads or writes the archive. It is designed for
  2741. those who don't need the more detailed (and voluminous) output of
  2742. @option{--block-number} (@option{-R}), but do want visual confirmation
  2743. that @command{tar} is actually making forward progress. By default it
  2744. prints a message each 10 records read or written. This can be changed
  2745. by giving it a numeric argument after an equal sign:
  2746. @smallexample
  2747. $ @kbd{tar -c --checkpoint=1000} /var
  2748. tar: Write checkpoint 1000
  2749. tar: Write checkpoint 2000
  2750. tar: Write checkpoint 3000
  2751. @end smallexample
  2752. This example shows the default checkpoint message used by
  2753. @command{tar}. If you place a dot immediately after the equal
  2754. sign, it will print a @samp{.} at each checkpoint. For example:
  2755. @smallexample
  2756. $ @kbd{tar -c --checkpoint=.1000} /var
  2757. ...
  2758. @end smallexample
  2759. @opindex show-omitted-dirs
  2760. @anchor{show-omitted-dirs}
  2761. The @option{--show-omitted-dirs} option, when reading an archive---with
  2762. @option{--list} or @option{--extract}, for example---causes a message
  2763. to be printed for each directory in the archive which is skipped.
  2764. This happens regardless of the reason for skipping: the directory might
  2765. not have been named on the command line (implicitly or explicitly),
  2766. it might be excluded by the use of the
  2767. @option{--exclude=@var{pattern}} option, or some other reason.
  2768. @opindex block-number
  2769. @cindex Block number where error occurred
  2770. @anchor{block-number}
  2771. If @option{--block-number} (@option{-R}) is used, @command{tar} prints, along with
  2772. every message it would normally produce, the block number within the
  2773. archive where the message was triggered. Also, supplementary messages
  2774. are triggered when reading blocks full of NULs, or when hitting end of
  2775. file on the archive. As of now, if the archive if properly terminated
  2776. with a NUL block, the reading of the file may stop before end of file
  2777. is met, so the position of end of file will not usually show when
  2778. @option{--block-number} (@option{-R}) is used. Note that @GNUTAR{}
  2779. drains the archive before exiting when reading the
  2780. archive from a pipe.
  2781. @cindex Error message, block number of
  2782. This option is especially useful when reading damaged archives, since
  2783. it helps pinpoint the damaged sections. It can also be used with
  2784. @option{--list} (@option{-t}) when listing a file-system backup tape, allowing you to
  2785. choose among several backup tapes when retrieving a file later, in
  2786. favor of the tape where the file appears earliest (closest to the
  2787. front of the tape). @xref{backup}.
  2788. @node interactive
  2789. @section Asking for Confirmation During Operations
  2790. @cindex Interactive operation
  2791. Typically, @command{tar} carries out a command without stopping for
  2792. further instructions. In some situations however, you may want to
  2793. exclude some files and archive members from the operation (for instance
  2794. if disk or storage space is tight). You can do this by excluding
  2795. certain files automatically (@pxref{Choosing}), or by performing
  2796. an operation interactively, using the @option{--interactive} (@option{-w}) option.
  2797. @command{tar} also accepts @option{--confirmation} for this option.
  2798. @opindex interactive
  2799. When the @option{--interactive} (@option{-w}) option is specified, before
  2800. reading, writing, or deleting files, @command{tar} first prints a message
  2801. for each such file, telling what operation it intends to take, then asks
  2802. for confirmation on the terminal. The actions which require
  2803. confirmation include adding a file to the archive, extracting a file
  2804. from the archive, deleting a file from the archive, and deleting a file
  2805. from disk. To confirm the action, you must type a line of input
  2806. beginning with @samp{y}. If your input line begins with anything other
  2807. than @samp{y}, @command{tar} skips that file.
  2808. If @command{tar} is reading the archive from the standard input,
  2809. @command{tar} opens the file @file{/dev/tty} to support the interactive
  2810. communications.
  2811. Verbose output is normally sent to standard output, separate from
  2812. other error messages. However, if the archive is produced directly
  2813. on standard output, then verbose output is mixed with errors on
  2814. @code{stderr}. Producing the archive on standard output may be used
  2815. as a way to avoid using disk space, when the archive is soon to be
  2816. consumed by another process reading it, say. Some people felt the need
  2817. of producing an archive on stdout, still willing to segregate between
  2818. verbose output and error output. A possible approach would be using a
  2819. named pipe to receive the archive, and having the consumer process to
  2820. read from that named pipe. This has the advantage of letting standard
  2821. output free to receive verbose output, all separate from errors.
  2822. @node operations
  2823. @chapter @GNUTAR{} Operations
  2824. @menu
  2825. * Basic tar::
  2826. * Advanced tar::
  2827. * create options::
  2828. * extract options::
  2829. * backup::
  2830. * Applications::
  2831. * looking ahead::
  2832. @end menu
  2833. @node Basic tar
  2834. @section Basic @GNUTAR{} Operations
  2835. The basic @command{tar} operations, @option{--create} (@option{-c}),
  2836. @option{--list} (@option{-t}) and @option{--extract} (@option{--get},
  2837. @option{-x}), are currently presented and described in the tutorial
  2838. chapter of this manual. This section provides some complementary notes
  2839. for these operations.
  2840. @table @option
  2841. @opindex create, complementary notes
  2842. @item --create
  2843. @itemx -c
  2844. Creating an empty archive would have some kind of elegance. One can
  2845. initialize an empty archive and later use @option{--append}
  2846. (@option{-r}) for adding all members. Some applications would not
  2847. welcome making an exception in the way of adding the first archive
  2848. member. On the other hand, many people reported that it is
  2849. dangerously too easy for @command{tar} to destroy a magnetic tape with
  2850. an empty archive@footnote{This is well described in @cite{Unix-haters
  2851. Handbook}, by Simson Garfinkel, Daniel Weise & Steven Strassmann, IDG
  2852. Books, ISBN 1-56884-203-1.}. The two most common errors are:
  2853. @enumerate
  2854. @item
  2855. Mistakingly using @code{create} instead of @code{extract}, when the
  2856. intent was to extract the full contents of an archive. This error
  2857. is likely: keys @kbd{c} and @kbd{x} are right next to each other on
  2858. the QWERTY keyboard. Instead of being unpacked, the archive then
  2859. gets wholly destroyed. When users speak about @dfn{exploding} an
  2860. archive, they usually mean something else :-).
  2861. @item
  2862. Forgetting the argument to @code{file}, when the intent was to create
  2863. an archive with a single file in it. This error is likely because a
  2864. tired user can easily add the @kbd{f} key to the cluster of option
  2865. letters, by the mere force of habit, without realizing the full
  2866. consequence of doing so. The usual consequence is that the single
  2867. file, which was meant to be saved, is rather destroyed.
  2868. @end enumerate
  2869. So, recognizing the likelihood and the catastrophical nature of these
  2870. errors, @GNUTAR{} now takes some distance from elegance, and
  2871. cowardly refuses to create an archive when @option{--create} option is
  2872. given, there are no arguments besides options, and
  2873. @option{--files-from} (@option{-T}) option is @emph{not} used. To get
  2874. around the cautiousness of @GNUTAR{} and nevertheless create an
  2875. archive with nothing in it, one may still use, as the value for the
  2876. @option{--files-from} option, a file with no names in it, as shown in
  2877. the following commands:
  2878. @smallexample
  2879. @kbd{tar --create --file=empty-archive.tar --files-from=/dev/null}
  2880. @kbd{tar cfT empty-archive.tar /dev/null}
  2881. @end smallexample
  2882. @opindex extract, complementary notes
  2883. @item --extract
  2884. @itemx --get
  2885. @itemx -x
  2886. A socket is stored, within a @GNUTAR{} archive, as a pipe.
  2887. @item @option{--list} (@option{-t})
  2888. @GNUTAR{} now shows dates as @samp{1996-08-30},
  2889. while it used to show them as @samp{Aug 30 1996}. Preferably,
  2890. people should get used to ISO 8601 dates. Local American dates should
  2891. be made available again with full date localization support, once
  2892. ready. In the meantime, programs not being localizable for dates
  2893. should prefer international dates, that's really the way to go.
  2894. Look up @url{http://www.ft.uni-erlangen.de/~mskuhn/iso-time.html} if you
  2895. are curious, it contains a detailed explanation of the ISO 8601 standard.
  2896. @end table
  2897. @node Advanced tar
  2898. @section Advanced @GNUTAR{} Operations
  2899. Now that you have learned the basics of using @GNUTAR{}, you may want
  2900. to learn about further ways in which @command{tar} can help you.
  2901. This chapter presents five, more advanced operations which you probably
  2902. won't use on a daily basis, but which serve more specialized functions.
  2903. We also explain the different styles of options and why you might want
  2904. to use one or another, or a combination of them in your @command{tar}
  2905. commands. Additionally, this chapter includes options which allow you to
  2906. define the output from @command{tar} more carefully, and provide help and
  2907. error correction in special circumstances.
  2908. @FIXME{check this after the chapter is actually revised to make sure
  2909. it still introduces the info in the chapter correctly : ).}
  2910. @menu
  2911. * Operations::
  2912. * append::
  2913. * update::
  2914. * concatenate::
  2915. * delete::
  2916. * compare::
  2917. @end menu
  2918. @node Operations
  2919. @subsection The Five Advanced @command{tar} Operations
  2920. @UNREVISED
  2921. In the last chapter, you learned about the first three operations to
  2922. @command{tar}. This chapter presents the remaining five operations to
  2923. @command{tar}: @option{--append}, @option{--update}, @option{--concatenate},
  2924. @option{--delete}, and @option{--compare}.
  2925. You are not likely to use these operations as frequently as those
  2926. covered in the last chapter; however, since they perform specialized
  2927. functions, they are quite useful when you do need to use them. We
  2928. will give examples using the same directory and files that you created
  2929. in the last chapter. As you may recall, the directory is called
  2930. @file{practice}, the files are @samp{jazz}, @samp{blues}, @samp{folk},
  2931. @samp{rock}, and the two archive files you created are
  2932. @samp{collection.tar} and @samp{music.tar}.
  2933. We will also use the archive files @samp{afiles.tar} and
  2934. @samp{bfiles.tar}. @samp{afiles.tar} contains the members @samp{apple},
  2935. @samp{angst}, and @samp{aspic}. @samp{bfiles.tar} contains the members
  2936. @samp{./birds}, @samp{baboon}, and @samp{./box}.
  2937. Unless we state otherwise, all practicing you do and examples you follow
  2938. in this chapter will take place in the @file{practice} directory that
  2939. you created in the previous chapter; see @ref{prepare for examples}.
  2940. (Below in this section, we will remind you of the state of the examples
  2941. where the last chapter left them.)
  2942. The five operations that we will cover in this chapter are:
  2943. @table @option
  2944. @item --append
  2945. @itemx -r
  2946. Add new entries to an archive that already exists.
  2947. @item --update
  2948. @itemx -r
  2949. Add more recent copies of archive members to the end of an archive, if
  2950. they exist.
  2951. @item --concatenate
  2952. @itemx --catenate
  2953. @itemx -A
  2954. Add one or more pre-existing archives to the end of another archive.
  2955. @item --delete
  2956. Delete items from an archive (does not work on tapes).
  2957. @item --compare
  2958. @itemx --diff
  2959. @itemx -d
  2960. Compare archive members to their counterparts in the file system.
  2961. @end table
  2962. @node append
  2963. @subsection How to Add Files to Existing Archives: @option{--append}
  2964. @UNREVISED
  2965. @opindex append
  2966. If you want to add files to an existing archive, you don't need to
  2967. create a new archive; you can use @option{--append} (@option{-r}).
  2968. The archive must already exist in order to use @option{--append}. (A
  2969. related operation is the @option{--update} operation; you can use this
  2970. to add newer versions of archive members to an existing archive. To learn how to
  2971. do this with @option{--update}, @pxref{update}.)
  2972. If you use @option{--append} to add a file that has the same name as an
  2973. archive member to an archive containing that archive member, then the
  2974. old member is not deleted. What does happen, however, is somewhat
  2975. complex. @command{tar} @emph{allows} you to have infinite number of files
  2976. with the same name. Some operations treat these same-named members no
  2977. differently than any other set of archive members: for example, if you
  2978. view an archive with @option{--list} (@option{-t}), you will see all
  2979. of those members listed, with their data modification times, owners, etc.
  2980. Other operations don't deal with these members as perfectly as you might
  2981. prefer; if you were to use @option{--extract} to extract the archive,
  2982. only the most recently added copy of a member with the same name as four
  2983. other members would end up in the working directory. This is because
  2984. @option{--extract} extracts an archive in the order the members appeared
  2985. in the archive; the most recently archived members will be extracted
  2986. last. Additionally, an extracted member will @emph{replace} a file of
  2987. the same name which existed in the directory already, and @command{tar}
  2988. will not prompt you about this@footnote{Unless you give it
  2989. @option{--keep-old-files} option, or the disk copy is newer than the
  2990. the one in the archive and you invoke @command{tar} with
  2991. @option{--keep-newer-files} option}. Thus, only the most recently archived
  2992. member will end up being extracted, as it will replace the one
  2993. extracted before it, and so on.
  2994. There exists a special option that allows you to get around this
  2995. behavior and extract (or list) only a particular copy of the file.
  2996. This is @option{--occurrence} option. If you run @command{tar} with
  2997. this option, it will extract only the first copy of the file. You
  2998. may also give this option an argument specifying the number of
  2999. copy to be extracted. Thus, for example if the archive
  3000. @file{archive.tar} contained three copies of file @file{myfile}, then
  3001. the command
  3002. @smallexample
  3003. tar --extract --file archive.tar --occurrence=2 myfile
  3004. @end smallexample
  3005. @noindent
  3006. would extract only the second copy. @xref{Option
  3007. Summary,---occurrence}, for the description of @option{--occurrence}
  3008. option.
  3009. @FIXME{ hag -- you might want to incorporate some of the above into the
  3010. MMwtSN node; not sure. i didn't know how to make it simpler...
  3011. There are a few ways to get around this. (maybe xref Multiple Members
  3012. with the Same Name.}
  3013. @cindex Members, replacing with other members
  3014. @cindex Replacing members with other members
  3015. If you want to replace an archive member, use @option{--delete} to
  3016. delete the member you want to remove from the archive, , and then use
  3017. @option{--append} to add the member you want to be in the archive. Note
  3018. that you can not change the order of the archive; the most recently
  3019. added member will still appear last. In this sense, you cannot truly
  3020. ``replace'' one member with another. (Replacing one member with another
  3021. will not work on certain types of media, such as tapes; see @ref{delete}
  3022. and @ref{Media}, for more information.)
  3023. @menu
  3024. * appending files:: Appending Files to an Archive
  3025. * multiple::
  3026. @end menu
  3027. @node appending files
  3028. @subsubsection Appending Files to an Archive
  3029. @UNREVISED
  3030. @cindex Adding files to an Archive
  3031. @cindex Appending files to an Archive
  3032. @cindex Archives, Appending files to
  3033. The simplest way to add a file to an already existing archive is the
  3034. @option{--append} (@option{-r}) operation, which writes specified
  3035. files into the archive whether or not they are already among the
  3036. archived files.
  3037. When you use @option{--append}, you @emph{must} specify file name
  3038. arguments, as there is no default. If you specify a file that already
  3039. exists in the archive, another copy of the file will be added to the
  3040. end of the archive. As with other operations, the member names of the
  3041. newly added files will be exactly the same as their names given on the
  3042. command line. The @option{--verbose} (@option{-v}) option will print
  3043. out the names of the files as they are written into the archive.
  3044. @option{--append} cannot be performed on some tape drives, unfortunately,
  3045. due to deficiencies in the formats those tape drives use. The archive
  3046. must be a valid @command{tar} archive, or else the results of using this
  3047. operation will be unpredictable. @xref{Media}.
  3048. To demonstrate using @option{--append} to add a file to an archive,
  3049. create a file called @file{rock} in the @file{practice} directory.
  3050. Make sure you are in the @file{practice} directory. Then, run the
  3051. following @command{tar} command to add @file{rock} to
  3052. @file{collection.tar}:
  3053. @smallexample
  3054. $ @kbd{tar --append --file=collection.tar rock}
  3055. @end smallexample
  3056. @noindent
  3057. If you now use the @option{--list} (@option{-t}) operation, you will see that
  3058. @file{rock} has been added to the archive:
  3059. @smallexample
  3060. $ @kbd{tar --list --file=collection.tar}
  3061. -rw-r--r-- me user 28 1996-10-18 16:31 jazz
  3062. -rw-r--r-- me user 21 1996-09-23 16:44 blues
  3063. -rw-r--r-- me user 20 1996-09-23 16:44 folk
  3064. -rw-r--r-- me user 20 1996-09-23 16:44 rock
  3065. @end smallexample
  3066. @node multiple
  3067. @subsubsection Multiple Files with the Same Name
  3068. You can use @option{--append} (@option{-r}) to add copies of files
  3069. which have been updated since the archive was created. (However, we
  3070. do not recommend doing this since there is another @command{tar}
  3071. option called @option{--update}; @xref{update}, for more information.
  3072. We describe this use of @option{--append} here for the sake of
  3073. completeness.) When you extract the archive, the older version will
  3074. be effectively lost. This works because files are extracted from an
  3075. archive in the order in which they were archived. Thus, when the
  3076. archive is extracted, a file archived later in time will replace a
  3077. file of the same name which was archived earlier, even though the
  3078. older version of the file will remain in the archive unless you delete
  3079. all versions of the file.
  3080. Supposing you change the file @file{blues} and then append the changed
  3081. version to @file{collection.tar}. As you saw above, the original
  3082. @file{blues} is in the archive @file{collection.tar}. If you change the
  3083. file and append the new version of the file to the archive, there will
  3084. be two copies in the archive. When you extract the archive, the older
  3085. version of the file will be extracted first, and then replaced by the
  3086. newer version when it is extracted.
  3087. You can append the new, changed copy of the file @file{blues} to the
  3088. archive in this way:
  3089. @smallexample
  3090. $ @kbd{tar --append --verbose --file=collection.tar blues}
  3091. blues
  3092. @end smallexample
  3093. @noindent
  3094. Because you specified the @option{--verbose} option, @command{tar} has
  3095. printed the name of the file being appended as it was acted on. Now
  3096. list the contents of the archive:
  3097. @smallexample
  3098. $ @kbd{tar --list --verbose --file=collection.tar}
  3099. -rw-r--r-- me user 28 1996-10-18 16:31 jazz
  3100. -rw-r--r-- me user 21 1996-09-23 16:44 blues
  3101. -rw-r--r-- me user 20 1996-09-23 16:44 folk
  3102. -rw-r--r-- me user 20 1996-09-23 16:44 rock
  3103. -rw-r--r-- me user 58 1996-10-24 18:30 blues
  3104. @end smallexample
  3105. @noindent
  3106. The newest version of @file{blues} is now at the end of the archive
  3107. (note the different creation dates and file sizes). If you extract
  3108. the archive, the older version of the file @file{blues} will be
  3109. replaced by the newer version. You can confirm this by extracting
  3110. the archive and running @samp{ls} on the directory.
  3111. If you wish to extract the first occurrence of the file @file{blues}
  3112. from the archive, use @option{--occurrence} option, as shown in
  3113. the following example:
  3114. @smallexample
  3115. $ @kbd{tar --extract -vv --occurrence --file=collection.tar blues}
  3116. -rw-r--r-- me user 21 1996-09-23 16:44 blues
  3117. @end smallexample
  3118. @xref{Writing}, for more information on @option{--extract} and
  3119. @xref{Option Summary, --occurrence}, for the description of
  3120. @option{--occurrence} option.
  3121. @node update
  3122. @subsection Updating an Archive
  3123. @UNREVISED
  3124. @cindex Updating an archive
  3125. @opindex update
  3126. In the previous section, you learned how to use @option{--append} to
  3127. add a file to an existing archive. A related operation is
  3128. @option{--update} (@option{-u}). The @option{--update} operation
  3129. updates a @command{tar} archive by comparing the date of the specified
  3130. archive members against the date of the file with the same name. If
  3131. the file has been modified more recently than the archive member, then
  3132. the newer version of the file is added to the archive (as with
  3133. @option{--append}).
  3134. Unfortunately, you cannot use @option{--update} with magnetic tape drives.
  3135. The operation will fail.
  3136. @FIXME{other examples of media on which --update will fail? need to ask
  3137. charles and/or mib/thomas/dave shevett..}
  3138. Both @option{--update} and @option{--append} work by adding to the end
  3139. of the archive. When you extract a file from the archive, only the
  3140. version stored last will wind up in the file system, unless you use
  3141. the @option{--backup} option. @FIXME-ref{Multiple Members with the
  3142. Same Name}
  3143. @menu
  3144. * how to update::
  3145. @end menu
  3146. @node how to update
  3147. @subsubsection How to Update an Archive Using @option{--update}
  3148. You must use file name arguments with the @option{--update}
  3149. (@option{-u}) operation. If you don't specify any files,
  3150. @command{tar} won't act on any files and won't tell you that it didn't
  3151. do anything (which may end up confusing you).
  3152. @c note: the above parenthetical added because in fact, this
  3153. @c behavior just confused the author. :-)
  3154. To see the @option{--update} option at work, create a new file,
  3155. @file{classical}, in your practice directory, and some extra text to the
  3156. file @file{blues}, using any text editor. Then invoke @command{tar} with
  3157. the @samp{update} operation and the @option{--verbose} (@option{-v})
  3158. option specified, using the names of all the files in the practice
  3159. directory as file name arguments:
  3160. @smallexample
  3161. $ @kbd{tar --update -v -f collection.tar blues folk rock classical}
  3162. blues
  3163. classical
  3164. $
  3165. @end smallexample
  3166. @noindent
  3167. Because we have specified verbose mode, @command{tar} prints out the names
  3168. of the files it is working on, which in this case are the names of the
  3169. files that needed to be updated. If you run @samp{tar --list} and look
  3170. at the archive, you will see @file{blues} and @file{classical} at its
  3171. end. There will be a total of two versions of the member @samp{blues};
  3172. the one at the end will be newer and larger, since you added text before
  3173. updating it.
  3174. (The reason @command{tar} does not overwrite the older file when updating
  3175. it is because writing to the middle of a section of tape is a difficult
  3176. process. Tapes are not designed to go backward. @xref{Media}, for more
  3177. information about tapes.
  3178. @option{--update} (@option{-u}) is not suitable for performing backups for two
  3179. reasons: it does not change directory content entries, and it
  3180. lengthens the archive every time it is used. The @GNUTAR{}
  3181. options intended specifically for backups are more
  3182. efficient. If you need to run backups, please consult @ref{Backups}.
  3183. @node concatenate
  3184. @subsection Combining Archives with @option{--concatenate}
  3185. @cindex Adding archives to an archive
  3186. @cindex Concatenating Archives
  3187. @opindex concatenate
  3188. @opindex catenate
  3189. @c @cindex @option{-A} described
  3190. Sometimes it may be convenient to add a second archive onto the end of
  3191. an archive rather than adding individual files to the archive. To add
  3192. one or more archives to the end of another archive, you should use the
  3193. @option{--concatenate} (@option{--catenate}, @option{-A}) operation.
  3194. To use @option{--concatenate}, give the first archive with
  3195. @option{--file} option and name the rest of archives to be
  3196. concatenated on the command line. The members, and their member
  3197. names, will be copied verbatim from those archives to the first one.
  3198. @FIXME-ref{This can cause multiple members to have the same name, for
  3199. information on how this affects reading the archive, Multiple
  3200. Members with the Same Name.}
  3201. The new, concatenated archive will be called by the same name as the
  3202. one given with the @option{--file} option. As usual, if you omit
  3203. @option{--file}, @command{tar} will use the value of the environment
  3204. variable @env{TAPE}, or, if this has not been set, the default archive name.
  3205. @FIXME{There is no way to specify a new name...}
  3206. To demonstrate how @option{--concatenate} works, create two small archives
  3207. called @file{bluesrock.tar} and @file{folkjazz.tar}, using the relevant
  3208. files from @file{practice}:
  3209. @smallexample
  3210. $ @kbd{tar -cvf bluesrock.tar blues rock}
  3211. blues
  3212. rock
  3213. $ @kbd{tar -cvf folkjazz.tar folk jazz}
  3214. folk
  3215. jazz
  3216. @end smallexample
  3217. @noindent
  3218. If you like, You can run @samp{tar --list} to make sure the archives
  3219. contain what they are supposed to:
  3220. @smallexample
  3221. $ @kbd{tar -tvf bluesrock.tar}
  3222. -rw-r--r-- melissa user 105 1997-01-21 19:42 blues
  3223. -rw-r--r-- melissa user 33 1997-01-20 15:34 rock
  3224. $ @kbd{tar -tvf jazzfolk.tar}
  3225. -rw-r--r-- melissa user 20 1996-09-23 16:44 folk
  3226. -rw-r--r-- melissa user 65 1997-01-30 14:15 jazz
  3227. @end smallexample
  3228. We can concatenate these two archives with @command{tar}:
  3229. @smallexample
  3230. $ @kbd{cd ..}
  3231. $ @kbd{tar --concatenate --file=bluesrock.tar jazzfolk.tar}
  3232. @end smallexample
  3233. If you now list the contents of the @file{bluesrock.tar}, you will see
  3234. that now it also contains the archive members of @file{jazzfolk.tar}:
  3235. @smallexample
  3236. $ @kbd{tar --list --file=bluesrock.tar}
  3237. blues
  3238. rock
  3239. folk
  3240. jazz
  3241. @end smallexample
  3242. When you use @option{--concatenate}, the source and target archives must
  3243. already exist and must have been created using compatible format
  3244. parameters. Notice, that @command{tar} does not check whether the
  3245. archives it concatenates have compatible formats, it does not
  3246. even check if the files are really tar archives.
  3247. Like @option{--append} (@option{-r}), this operation cannot be performed on some
  3248. tape drives, due to deficiencies in the formats those tape drives use.
  3249. @cindex @code{concatenate} vs @command{cat}
  3250. @cindex @command{cat} vs @code{concatenate}
  3251. It may seem more intuitive to you to want or try to use @command{cat} to
  3252. concatenate two archives instead of using the @option{--concatenate}
  3253. operation; after all, @command{cat} is the utility for combining files.
  3254. However, @command{tar} archives incorporate an end-of-file marker which
  3255. must be removed if the concatenated archives are to be read properly as
  3256. one archive. @option{--concatenate} removes the end-of-archive marker
  3257. from the target archive before each new archive is appended. If you use
  3258. @command{cat} to combine the archives, the result will not be a valid
  3259. @command{tar} format archive. If you need to retrieve files from an
  3260. archive that was added to using the @command{cat} utility, use the
  3261. @option{--ignore-zeros} (@option{-i}) option. @xref{Ignore Zeros}, for further
  3262. information on dealing with archives improperly combined using the
  3263. @command{cat} shell utility.
  3264. @node delete
  3265. @subsection Removing Archive Members Using @option{--delete}
  3266. @UNREVISED
  3267. @cindex Deleting files from an archive
  3268. @cindex Removing files from an archive
  3269. @opindex delete
  3270. You can remove members from an archive by using the @option{--delete}
  3271. option. Specify the name of the archive with @option{--file}
  3272. (@option{-f}) and then specify the names of the members to be deleted;
  3273. if you list no member names, nothing will be deleted. The
  3274. @option{--verbose} option will cause @command{tar} to print the names
  3275. of the members as they are deleted. As with @option{--extract}, you
  3276. must give the exact member names when using @samp{tar --delete}.
  3277. @option{--delete} will remove all versions of the named file from the
  3278. archive. The @option{--delete} operation can run very slowly.
  3279. Unlike other operations, @option{--delete} has no short form.
  3280. @cindex Tapes, using @option{--delete} and
  3281. @cindex Deleting from tape archives
  3282. This operation will rewrite the archive. You can only use
  3283. @option{--delete} on an archive if the archive device allows you to
  3284. write to any point on the media, such as a disk; because of this, it
  3285. does not work on magnetic tapes. Do not try to delete an archive member
  3286. from a magnetic tape; the action will not succeed, and you will be
  3287. likely to scramble the archive and damage your tape. There is no safe
  3288. way (except by completely re-writing the archive) to delete files from
  3289. most kinds of magnetic tape. @xref{Media}.
  3290. To delete all versions of the file @file{blues} from the archive
  3291. @file{collection.tar} in the @file{practice} directory, make sure you
  3292. are in that directory, and then,
  3293. @smallexample
  3294. $ @kbd{tar --list --file=collection.tar}
  3295. blues
  3296. folk
  3297. jazz
  3298. rock
  3299. $ @kbd{tar --delete --file=collection.tar blues}
  3300. $ @kbd{tar --list --file=collection.tar}
  3301. folk
  3302. jazz
  3303. rock
  3304. $
  3305. @end smallexample
  3306. @FIXME{Check if the above listing is actually produced after running
  3307. all the examples on collection.tar.}
  3308. The @option{--delete} option has been reported to work properly when
  3309. @command{tar} acts as a filter from @code{stdin} to @code{stdout}.
  3310. @node compare
  3311. @subsection Comparing Archive Members with the File System
  3312. @cindex Verifying the currency of an archive
  3313. @UNREVISED
  3314. @opindex compare
  3315. The @option{--compare} (@option{-d}), or @option{--diff} operation compares
  3316. specified archive members against files with the same names, and then
  3317. reports differences in file size, mode, owner, modification date and
  3318. contents. You should @emph{only} specify archive member names, not file
  3319. names. If you do not name any members, then @command{tar} will compare the
  3320. entire archive. If a file is represented in the archive but does not
  3321. exist in the file system, @command{tar} reports a difference.
  3322. You have to specify the record size of the archive when modifying an
  3323. archive with a non-default record size.
  3324. @command{tar} ignores files in the file system that do not have
  3325. corresponding members in the archive.
  3326. The following example compares the archive members @file{rock},
  3327. @file{blues} and @file{funk} in the archive @file{bluesrock.tar} with
  3328. files of the same name in the file system. (Note that there is no file,
  3329. @file{funk}; @command{tar} will report an error message.)
  3330. @smallexample
  3331. $ @kbd{tar --compare --file=bluesrock.tar rock blues funk}
  3332. rock
  3333. blues
  3334. tar: funk not found in archive
  3335. @end smallexample
  3336. The spirit behind the @option{--compare} (@option{--diff},
  3337. @option{-d}) option is to check whether the archive represents the
  3338. current state of files on disk, more than validating the integrity of
  3339. the archive media. For this later goal, @xref{verify}.
  3340. @node create options
  3341. @section Options Used by @option{--create}
  3342. @opindex create, additional options
  3343. The previous chapter described the basics of how to use
  3344. @option{--create} (@option{-c}) to create an archive from a set of files.
  3345. @xref{create}. This section described advanced options to be used with
  3346. @option{--create}.
  3347. @menu
  3348. * Ignore Failed Read::
  3349. @end menu
  3350. @node Ignore Failed Read
  3351. @subsection Ignore Fail Read
  3352. @table @option
  3353. @item --ignore-failed-read
  3354. Do not exit with nonzero on unreadable files or directories.
  3355. @end table
  3356. @node extract options
  3357. @section Options Used by @option{--extract}
  3358. @UNREVISED
  3359. @opindex extract, additional options
  3360. The previous chapter showed how to use @option{--extract} to extract
  3361. an archive into the file system. Various options cause @command{tar} to
  3362. extract more information than just file contents, such as the owner,
  3363. the permissions, the modification date, and so forth. This section
  3364. presents options to be used with @option{--extract} when certain special
  3365. considerations arise. You may review the information presented in
  3366. @ref{extract} for more basic information about the
  3367. @option{--extract} operation.
  3368. @menu
  3369. * Reading:: Options to Help Read Archives
  3370. * Writing:: Changing How @command{tar} Writes Files
  3371. * Scarce:: Coping with Scarce Resources
  3372. @end menu
  3373. @node Reading
  3374. @subsection Options to Help Read Archives
  3375. @cindex Options when reading archives
  3376. @UNREVISED
  3377. @cindex Reading incomplete records
  3378. @cindex Records, incomplete
  3379. @opindex read-full-records
  3380. Normally, @command{tar} will request data in full record increments from
  3381. an archive storage device. If the device cannot return a full record,
  3382. @command{tar} will report an error. However, some devices do not always
  3383. return full records, or do not require the last record of an archive to
  3384. be padded out to the next record boundary. To keep reading until you
  3385. obtain a full record, or to accept an incomplete record if it contains
  3386. an end-of-archive marker, specify the @option{--read-full-records} (@option{-B}) option
  3387. in conjunction with the @option{--extract} or @option{--list} operations.
  3388. @xref{Blocking}.
  3389. The @option{--read-full-records} (@option{-B}) option is turned on by default when
  3390. @command{tar} reads an archive from standard input, or from a remote
  3391. machine. This is because on BSD Unix systems, attempting to read a
  3392. pipe returns however much happens to be in the pipe, even if it is
  3393. less than was requested. If this option were not enabled, @command{tar}
  3394. would fail as soon as it read an incomplete record from the pipe.
  3395. If you're not sure of the blocking factor of an archive, you can
  3396. read the archive by specifying @option{--read-full-records} (@option{-B}) and
  3397. @option{--blocking-factor=@var{512-size}} (@option{-b
  3398. @var{512-size}}), using a blocking factor larger than what the archive
  3399. uses. This lets you avoid having to determine the blocking factor
  3400. of an archive. @xref{Blocking Factor}.
  3401. @menu
  3402. * read full records::
  3403. * Ignore Zeros::
  3404. @end menu
  3405. @node read full records
  3406. @unnumberedsubsubsec Reading Full Records
  3407. @FIXME{need sentence or so of intro here}
  3408. @table @option
  3409. @opindex read-full-records
  3410. @item --read-full-records
  3411. @item -B
  3412. Use in conjunction with @option{--extract} (@option{--get},
  3413. @option{-x}) to read an archive which contains incomplete records, or
  3414. one which has a blocking factor less than the one specified.
  3415. @end table
  3416. @node Ignore Zeros
  3417. @unnumberedsubsubsec Ignoring Blocks of Zeros
  3418. @cindex End-of-archive blocks, ignoring
  3419. @cindex Ignoring end-of-archive blocks
  3420. @opindex ignore-zeros
  3421. Normally, @command{tar} stops reading when it encounters a block of zeros
  3422. between file entries (which usually indicates the end of the archive).
  3423. @option{--ignore-zeros} (@option{-i}) allows @command{tar} to
  3424. completely read an archive which contains a block of zeros before the
  3425. end (i.e., a damaged archive, or one that was created by concatenating
  3426. several archives together).
  3427. The @option{--ignore-zeros} (@option{-i}) option is turned off by default because many
  3428. versions of @command{tar} write garbage after the end-of-archive entry,
  3429. since that part of the media is never supposed to be read. @GNUTAR{}
  3430. does not write after the end of an archive, but seeks to
  3431. maintain compatiblity among archiving utilities.
  3432. @table @option
  3433. @item --ignore-zeros
  3434. @itemx -i
  3435. To ignore blocks of zeros (i.e., end-of-archive entries) which may be
  3436. encountered while reading an archive. Use in conjunction with
  3437. @option{--extract} or @option{--list}.
  3438. @end table
  3439. @node Writing
  3440. @subsection Changing How @command{tar} Writes Files
  3441. @UNREVISED
  3442. @FIXME{Introductory paragraph}
  3443. @menu
  3444. * Dealing with Old Files::
  3445. * Overwrite Old Files::
  3446. * Keep Old Files::
  3447. * Keep Newer Files::
  3448. * Unlink First::
  3449. * Recursive Unlink::
  3450. * Data Modification Times::
  3451. * Setting Access Permissions::
  3452. * Directory Modification Times and Permissions::
  3453. * Writing to Standard Output::
  3454. * Writing to an External Program::
  3455. * remove files::
  3456. @end menu
  3457. @node Dealing with Old Files
  3458. @unnumberedsubsubsec Options Controlling the Overwriting of Existing Files
  3459. @opindex overwrite-dir, introduced
  3460. When extracting files, if @command{tar} discovers that the extracted
  3461. file already exists, it normally replaces the file by removing it before
  3462. extracting it, to prevent confusion in the presence of hard or symbolic
  3463. links. (If the existing file is a symbolic link, it is removed, not
  3464. followed.) However, if a directory cannot be removed because it is
  3465. nonempty, @command{tar} normally overwrites its metadata (ownership,
  3466. permission, etc.). The @option{--overwrite-dir} option enables this
  3467. default behavior. To be more cautious and preserve the metadata of
  3468. such a directory, use the @option{--no-overwrite-dir} option.
  3469. @cindex Overwriting old files, prevention
  3470. @opindex keep-old-files, introduced
  3471. To be even more cautious and prevent existing files from being replaced, use
  3472. the @option{--keep-old-files} (@option{-k}) option. It causes @command{tar} to refuse
  3473. to replace or update a file that already exists, i.e., a file with the
  3474. same name as an archive member prevents extraction of that archive
  3475. member. Instead, it reports an error.
  3476. @opindex overwrite, introduced
  3477. To be more aggressive about altering existing files, use the
  3478. @option{--overwrite} option. It causes @command{tar} to overwrite
  3479. existing files and to follow existing symbolic links when extracting.
  3480. @cindex Protecting old files
  3481. Some people argue that @GNUTAR{} should not hesitate
  3482. to overwrite files with other files when extracting. When extracting
  3483. a @command{tar} archive, they expect to see a faithful copy of the
  3484. state of the file system when the archive was created. It is debatable
  3485. that this would always be a proper behavior. For example, suppose one
  3486. has an archive in which @file{usr/local} is a link to
  3487. @file{usr/local2}. Since then, maybe the site removed the link and
  3488. renamed the whole hierarchy from @file{/usr/local2} to
  3489. @file{/usr/local}. Such things happen all the time. I guess it would
  3490. not be welcome at all that @GNUTAR{} removes the
  3491. whole hierarchy just to make room for the link to be reinstated
  3492. (unless it @emph{also} simultaneously restores the full
  3493. @file{/usr/local2}, of course!) @GNUTAR{} is indeed
  3494. able to remove a whole hierarchy to reestablish a symbolic link, for
  3495. example, but @emph{only if} @option{--recursive-unlink} is specified
  3496. to allow this behavior. In any case, single files are silently
  3497. removed.
  3498. @opindex unlink-first, introduced
  3499. Finally, the @option{--unlink-first} (@option{-U}) option can improve performance in
  3500. some cases by causing @command{tar} to remove files unconditionally
  3501. before extracting them.
  3502. @node Overwrite Old Files
  3503. @unnumberedsubsubsec Overwrite Old Files
  3504. @table @option
  3505. @opindex overwrite
  3506. @item --overwrite
  3507. Overwrite existing files and directory metadata when extracting files
  3508. from an archive.
  3509. This causes @command{tar} to write extracted files into the file system without
  3510. regard to the files already on the system; i.e., files with the same
  3511. names as archive members are overwritten when the archive is extracted.
  3512. It also causes @command{tar} to extract the ownership, permissions,
  3513. and time stamps onto any preexisting files or directories.
  3514. If the name of a corresponding file name is a symbolic link, the file
  3515. pointed to by the symbolic link will be overwritten instead of the
  3516. symbolic link itself (if this is possible). Moreover, special devices,
  3517. empty directories and even symbolic links are automatically removed if
  3518. they are in the way of extraction.
  3519. Be careful when using the @option{--overwrite} option, particularly when
  3520. combined with the @option{--absolute-names} (@option{-P}) option, as this combination
  3521. can change the contents, ownership or permissions of any file on your
  3522. system. Also, many systems do not take kindly to overwriting files that
  3523. are currently being executed.
  3524. @opindex overwrite-dir
  3525. @item --overwrite-dir
  3526. Overwrite the metadata of directories when extracting files from an
  3527. archive, but remove other files before extracting.
  3528. @end table
  3529. @node Keep Old Files
  3530. @unnumberedsubsubsec Keep Old Files
  3531. @table @option
  3532. @opindex keep-old-files
  3533. @item --keep-old-files
  3534. @itemx -k
  3535. Do not replace existing files from archive. The
  3536. @option{--keep-old-files} (@option{-k}) option prevents @command{tar}
  3537. from replacing existing files with files with the same name from the
  3538. archive. The @option{--keep-old-files} option is meaningless with
  3539. @option{--list} (@option{-t}). Prevents @command{tar} from replacing
  3540. files in the file system during extraction.
  3541. @end table
  3542. @node Keep Newer Files
  3543. @unnumberedsubsubsec Keep Newer Files
  3544. @table @option
  3545. @opindex keep-newer-files
  3546. @item --keep-newer-files
  3547. Do not replace existing files that are newer than their archive
  3548. copies. This option is meaningless with @option{--list} (@option{-t}).
  3549. @end table
  3550. @node Unlink First
  3551. @unnumberedsubsubsec Unlink First
  3552. @table @option
  3553. @opindex unlink-first
  3554. @item --unlink-first
  3555. @itemx -U
  3556. Remove files before extracting over them.
  3557. This can make @command{tar} run a bit faster if you know in advance
  3558. that the extracted files all need to be removed. Normally this option
  3559. slows @command{tar} down slightly, so it is disabled by default.
  3560. @end table
  3561. @node Recursive Unlink
  3562. @unnumberedsubsubsec Recursive Unlink
  3563. @table @option
  3564. @opindex recursive-unlink
  3565. @item --recursive-unlink
  3566. When this option is specified, try removing files and directory hierarchies
  3567. before extracting over them. @emph{This is a dangerous option!}
  3568. @end table
  3569. If you specify the @option{--recursive-unlink} option,
  3570. @command{tar} removes @emph{anything} that keeps you from extracting a file
  3571. as far as current permissions will allow it. This could include removal
  3572. of the contents of a full directory hierarchy.
  3573. @node Data Modification Times
  3574. @unnumberedsubsubsec Setting Data Modification Times
  3575. @cindex Data modification times of extracted files
  3576. @cindex Modification times of extracted files
  3577. Normally, @command{tar} sets the data modification times of extracted
  3578. files to the corresponding times recorded for the files in the archive, but
  3579. limits the permissions of extracted files by the current @code{umask}
  3580. setting.
  3581. To set the data modification times of extracted files to the time when
  3582. the files were extracted, use the @option{--touch} (@option{-m}) option in
  3583. conjunction with @option{--extract} (@option{--get}, @option{-x}).
  3584. @table @option
  3585. @opindex touch
  3586. @item --touch
  3587. @itemx -m
  3588. Sets the data modification time of extracted archive members to the time
  3589. they were extracted, not the time recorded for them in the archive.
  3590. Use in conjunction with @option{--extract} (@option{--get}, @option{-x}).
  3591. @end table
  3592. @node Setting Access Permissions
  3593. @unnumberedsubsubsec Setting Access Permissions
  3594. @cindex Permissions of extracted files
  3595. @cindex Modes of extracted files
  3596. To set the modes (access permissions) of extracted files to those
  3597. recorded for those files in the archive, use @option{--same-permissions}
  3598. in conjunction with the @option{--extract} (@option{--get},
  3599. @option{-x}) operation.
  3600. @table @option
  3601. @opindex preserve-permission
  3602. @opindex same-permission
  3603. @item --preserve-permission
  3604. @itemx --same-permission
  3605. @c @itemx --ignore-umask
  3606. @itemx -p
  3607. Set modes of extracted archive members to those recorded in the
  3608. archive, instead of current umask settings. Use in conjunction with
  3609. @option{--extract} (@option{--get}, @option{-x}).
  3610. @end table
  3611. @node Directory Modification Times and Permissions
  3612. @unnumberedsubsubsec Directory Modification Times and Permissions
  3613. After sucessfully extracting a file member, @GNUTAR{} normally
  3614. restores its permissions and modification times, as described in the
  3615. previous sections. This cannot be done for directories, because
  3616. after extracting a directory @command{tar} will almost certainly
  3617. extract files into that directory and this will cause the directory
  3618. modification time to be updated. Moreover, restoring that directory
  3619. permissions may not permit file creation within it. Thus, restoring
  3620. directory permissions and modification times must be delayed at least
  3621. until all files have been extracted into that directory. @GNUTAR{}
  3622. restores directories using the following approach.
  3623. The extracted directories are created with the mode specified in the
  3624. archive, as modified by the umask of the user, which gives sufficient
  3625. permissions to allow file creation. The meta-information about the
  3626. directory is recorded in the temporary list of directories. When
  3627. preparing to extract next archive member, @GNUTAR{} checks if the
  3628. directory prefix of this file contains the remembered directory. If
  3629. it does not, the program assumes that all files have been extracted
  3630. into that directory, restores its modification time and permissions
  3631. and removes its entry from the internal list. This approach allows
  3632. to correctly restore directory meta-information in the majority of
  3633. cases, while keeping memory requirements sufficiently small. It is
  3634. based on the fact, that most @command{tar} archives use the predefined
  3635. order of members: first the directory, then all the files and
  3636. subdirectories in that directory.
  3637. However, this is not always true. The most important exception are
  3638. incremental archives (@pxref{Incremental Dumps}). The member order in
  3639. an incremental archive is reversed: first all directory members are
  3640. stored, followed by other (non-directory) members. So, when extracting
  3641. from incremental archives, @GNUTAR{} alters the above procedure. It
  3642. remebers all restored directories, and restores their meta-data
  3643. only after the entire archive has been processed. Notice, that you do
  3644. not need to specity any special options for that, as @GNUTAR{}
  3645. automatically detects archives in incremental format.
  3646. There may be cases, when such processing is required for normal archives
  3647. too. Consider the following example:
  3648. @smallexample
  3649. @group
  3650. $ @kbd{tar --no-recursion -cvf archive \
  3651. foo foo/file1 bar bar/file foo/file2}
  3652. foo/
  3653. foo/file1
  3654. bar/
  3655. bar/file
  3656. foo/file2
  3657. @end group
  3658. @end smallexample
  3659. During the normal operation, after encountering @file{bar}
  3660. @GNUTAR{} will assume that all files from the directory @file{foo}
  3661. were already extracted and will therefore restore its timestamp and
  3662. permission bits. However, after extracting @file{foo/file2} the
  3663. directory timestamp will be offset again.
  3664. To correctly restore directory meta-information in such cases, use
  3665. @option{delay-directory-restore} command line option:
  3666. @table @option
  3667. @opindex delay-directory-restore
  3668. @item --delay-directory-restore
  3669. Delays restoring of the modification times and permissions of extracted
  3670. directories until the end of extraction. This way, correct
  3671. meta-information is restored even if the archive has unusual member
  3672. ordering.
  3673. @opindex no-delay-directory-restore
  3674. @item --no-delay-directory-restore
  3675. Cancel the effect of the previous @option{--delay-directory-restore}.
  3676. Use this option if you have used @option{--delay-directory-restore} in
  3677. @env{TAR_OPTIONS} variable (@pxref{TAR_OPTIONS}) and wish to
  3678. temporarily disable it.
  3679. @end table
  3680. @node Writing to Standard Output
  3681. @unnumberedsubsubsec Writing to Standard Output
  3682. @cindex Writing extracted files to standard output
  3683. @cindex Standard output, writing extracted files to
  3684. To write the extracted files to the standard output, instead of
  3685. creating the files on the file system, use @option{--to-stdout} (@option{-O}) in
  3686. conjunction with @option{--extract} (@option{--get}, @option{-x}). This option is useful if you are
  3687. extracting files to send them through a pipe, and do not need to
  3688. preserve them in the file system. If you extract multiple members,
  3689. they appear on standard output concatenated, in the order they are
  3690. found in the archive.
  3691. @table @option
  3692. @opindex to-stdout
  3693. @item --to-stdout
  3694. @itemx -O
  3695. Writes files to the standard output. Use only in conjunction with
  3696. @option{--extract} (@option{--get}, @option{-x}). When this option is
  3697. used, instead of creating the files specified, @command{tar} writes
  3698. the contents of the files extracted to its standard output. This may
  3699. be useful if you are only extracting the files in order to send them
  3700. through a pipe. This option is meaningless with @option{--list}
  3701. (@option{-t}).
  3702. @end table
  3703. This can be useful, for example, if you have a tar archive containing
  3704. a big file and don't want to store the file on disk before processing
  3705. it. You can use a command like this:
  3706. @smallexample
  3707. tar -xOzf foo.tgz bigfile | process
  3708. @end smallexample
  3709. or even like this if you want to process the concatenation of the files:
  3710. @smallexample
  3711. tar -xOzf foo.tgz bigfile1 bigfile2 | process
  3712. @end smallexample
  3713. Hovewer, @option{--to-command} may be more convenient for use with
  3714. multiple files. See the next section.
  3715. @node Writing to an External Program
  3716. @unnumberedsubsubsec Writing to an External Program
  3717. You can instruct @command{tar} to send the contents of each extracted
  3718. file to the standard input of an external program:
  3719. @table @option
  3720. @opindex to-command
  3721. @item --to-command=@var{command}
  3722. Extract files and pipe their contents to the standard input of
  3723. @var{command}. When this option is used, instead of creating the
  3724. files specified, @command{tar} invokes @var{command} and pipes the
  3725. contents of the files to its standard output. @var{Command} may
  3726. contain command line arguments. The program is executed via
  3727. @code{sh -c}. Notice, that @var{command} is executed once for each regular file
  3728. extracted. Non-regular files (directories, etc.) are ignored when this
  3729. option is used.
  3730. @end table
  3731. The command can obtain the information about the file it processes
  3732. from the following environment variables:
  3733. @table @var
  3734. @vrindex TAR_FILETYPE, to-command environment
  3735. @item TAR_FILETYPE
  3736. Type of the file. It is a single letter with the following meaning:
  3737. @multitable @columnfractions 0.10 0.90
  3738. @item f @tab Regular file
  3739. @item d @tab Directory
  3740. @item l @tab Symbolic link
  3741. @item h @tab Hard link
  3742. @item b @tab Block device
  3743. @item c @tab Character device
  3744. @end multitable
  3745. Currently only regular files are supported.
  3746. @vrindex TAR_MODE, to-command environment
  3747. @item TAR_MODE
  3748. File mode, an octal number.
  3749. @vrindex TAR_FILENAME, to-command environment
  3750. @item TAR_FILENAME
  3751. The name of the file.
  3752. @vrindex TAR_REALNAME, to-command environment
  3753. @item TAR_REALNAME
  3754. Name of the file as stored in the archive.
  3755. @vrindex TAR_UNAME, to-command environment
  3756. @item TAR_UNAME
  3757. Name of the file owner.
  3758. @vrindex TAR_GNAME, to-command environment
  3759. @item TAR_GNAME
  3760. Name of the file owner group.
  3761. @vrindex TAR_ATIME, to-command environment
  3762. @item TAR_ATIME
  3763. Time of last access. It is a decimal number, representing seconds
  3764. since the epoch. If the archive provides times with nanosecond
  3765. precision, the nanoseconds are appended to the timestamp after a
  3766. decimal point.
  3767. @vrindex TAR_MTIME, to-command environment
  3768. @item TAR_MTIME
  3769. Time of last modification.
  3770. @vrindex TAR_CTIME, to-command environment
  3771. @item TAR_CTIME
  3772. Time of last status change.
  3773. @vrindex TAR_SIZE, to-command environment
  3774. @item TAR_SIZE
  3775. Size of the file.
  3776. @vrindex TAR_UID, to-command environment
  3777. @item TAR_UID
  3778. UID of the file owner.
  3779. @vrindex TAR_GID, to-command environment
  3780. @item TAR_GID
  3781. GID of the file owner.
  3782. @end table
  3783. In addition to these variables, @env{TAR_VERSION} contains the
  3784. @GNUTAR{} version number.
  3785. If @var{command} exits with a non-0 status, @command{tar} will print
  3786. an error message similar to the following:
  3787. @smallexample
  3788. tar: 2345: Child returned status 1
  3789. @end smallexample
  3790. Here, @samp{2345} is the PID of the finished process.
  3791. If this behavior is not wanted, use @option{--ignore-command-error}:
  3792. @table @option
  3793. @opindex ignore-command-error
  3794. @item --ignore-command-error
  3795. Ignore exit codes of subprocesses. Notice that if the program
  3796. exits on signal or otherwise terminates abnormally, the error message
  3797. will be printed even if this option is used.
  3798. @opindex no-ignore-command-error
  3799. @item --no-ignore-command-error
  3800. Cancel the effect of any previous @option{--ignore-command-error}
  3801. option. This option is useful if you have set
  3802. @option{--ignore-command-error} in @env{TAR_OPTIONS}
  3803. (@pxref{TAR_OPTIONS}) and wish to temporarily cancel it.
  3804. @end table
  3805. @node remove files
  3806. @unnumberedsubsubsec Removing Files
  3807. @FIXME{The section is too terse. Something more to add? An example,
  3808. maybe?}
  3809. @table @option
  3810. @opindex remove-files
  3811. @item --remove-files
  3812. Remove files after adding them to the archive.
  3813. @end table
  3814. @node Scarce
  3815. @subsection Coping with Scarce Resources
  3816. @UNREVISED
  3817. @cindex Small memory
  3818. @cindex Running out of space
  3819. @menu
  3820. * Starting File::
  3821. * Same Order::
  3822. @end menu
  3823. @node Starting File
  3824. @unnumberedsubsubsec Starting File
  3825. @table @option
  3826. @opindex starting-file
  3827. @item --starting-file=@var{name}
  3828. @itemx -K @var{name}
  3829. Starts an operation in the middle of an archive. Use in conjunction
  3830. with @option{--extract} (@option{--get}, @option{-x}) or @option{--list} (@option{-t}).
  3831. @end table
  3832. @cindex Middle of the archive, starting in the
  3833. If a previous attempt to extract files failed due to lack of disk
  3834. space, you can use @option{--starting-file=@var{name}} (@option{-K
  3835. @var{name}}) to start extracting only after member @var{name} of the
  3836. archive. This assumes, of course, that there is now free space, or
  3837. that you are now extracting into a different file system. (You could
  3838. also choose to suspend @command{tar}, remove unnecessary files from
  3839. the file system, and then restart the same @command{tar} operation.
  3840. In this case, @option{--starting-file} is not necessary.
  3841. @xref{Incremental Dumps}, @xref{interactive}, and @ref{exclude}.)
  3842. @node Same Order
  3843. @unnumberedsubsubsec Same Order
  3844. @table @option
  3845. @cindex Large lists of file names on small machines
  3846. @opindex same-order
  3847. @opindex preserve-order
  3848. @item --same-order
  3849. @itemx --preserve-order
  3850. @itemx -s
  3851. To process large lists of file names on machines with small amounts of
  3852. memory. Use in conjunction with @option{--compare} (@option{--diff},
  3853. @option{-d}), @option{--list} (@option{-t}) or @option{--extract}
  3854. (@option{--get}, @option{-x}).
  3855. @end table
  3856. The @option{--same-order} (@option{--preserve-order}, @option{-s}) option tells @command{tar} that the list of file
  3857. names to be listed or extracted is sorted in the same order as the
  3858. files in the archive. This allows a large list of names to be used,
  3859. even on a small machine that would not otherwise be able to hold all
  3860. the names in memory at the same time. Such a sorted list can easily be
  3861. created by running @samp{tar -t} on the archive and editing its output.
  3862. This option is probably never needed on modern computer systems.
  3863. @node backup
  3864. @section Backup options
  3865. @cindex backup options
  3866. @GNUTAR{} offers options for making backups of files
  3867. before writing new versions. These options control the details of
  3868. these backups. They may apply to the archive itself before it is
  3869. created or rewritten, as well as individual extracted members. Other
  3870. @acronym{GNU} programs (@command{cp}, @command{install}, @command{ln},
  3871. and @command{mv}, for example) offer similar options.
  3872. Backup options may prove unexpectedly useful when extracting archives
  3873. containing many members having identical name, or when extracting archives
  3874. on systems having file name limitations, making different members appear
  3875. has having similar names through the side-effect of name truncation.
  3876. (This is true only if we have a good scheme for truncated backup names,
  3877. which I'm not sure at all: I suspect work is needed in this area.)
  3878. When any existing file is backed up before being overwritten by extraction,
  3879. then clashing files are automatically be renamed to be unique, and the
  3880. true name is kept for only the last file of a series of clashing files.
  3881. By using verbose mode, users may track exactly what happens.
  3882. At the detail level, some decisions are still experimental, and may
  3883. change in the future, we are waiting comments from our users. So, please
  3884. do not learn to depend blindly on the details of the backup features.
  3885. For example, currently, directories themselves are never renamed through
  3886. using these options, so, extracting a file over a directory still has
  3887. good chances to fail. Also, backup options apply to created archives,
  3888. not only to extracted members. For created archives, backups will not
  3889. be attempted when the archive is a block or character device, or when it
  3890. refers to a remote file.
  3891. For the sake of simplicity and efficiency, backups are made by renaming old
  3892. files prior to creation or extraction, and not by copying. The original
  3893. name is restored if the file creation fails. If a failure occurs after a
  3894. partial extraction of a file, both the backup and the partially extracted
  3895. file are kept.
  3896. @table @samp
  3897. @item --backup[=@var{method}]
  3898. @opindex backup
  3899. @vindex VERSION_CONTROL
  3900. @cindex backups
  3901. Back up files that are about to be overwritten or removed.
  3902. Without this option, the original versions are destroyed.
  3903. Use @var{method} to determine the type of backups made.
  3904. If @var{method} is not specified, use the value of the @env{VERSION_CONTROL}
  3905. environment variable. And if @env{VERSION_CONTROL} is not set,
  3906. use the @samp{existing} method.
  3907. @vindex version-control @r{Emacs variable}
  3908. This option corresponds to the Emacs variable @samp{version-control};
  3909. the same values for @var{method} are accepted as in Emacs. This option
  3910. also allows more descriptive names. The valid @var{method}s are:
  3911. @table @samp
  3912. @item t
  3913. @itemx numbered
  3914. @cindex numbered @r{backup method}
  3915. Always make numbered backups.
  3916. @item nil
  3917. @itemx existing
  3918. @cindex existing @r{backup method}
  3919. Make numbered backups of files that already have them, simple backups
  3920. of the others.
  3921. @item never
  3922. @itemx simple
  3923. @cindex simple @r{backup method}
  3924. Always make simple backups.
  3925. @end table
  3926. @item --suffix=@var{suffix}
  3927. @opindex suffix
  3928. @cindex backup suffix
  3929. @vindex SIMPLE_BACKUP_SUFFIX
  3930. Append @var{suffix} to each backup file made with @option{--backup}. If this
  3931. option is not specified, the value of the @env{SIMPLE_BACKUP_SUFFIX}
  3932. environment variable is used. And if @env{SIMPLE_BACKUP_SUFFIX} is not
  3933. set, the default is @samp{~}, just as in Emacs.
  3934. @end table
  3935. Some people express the desire to @emph{always} use the @option{--backup}
  3936. option, by defining some kind of alias or script. This is not as easy
  3937. as one may think, due to the fact that old style options should appear first
  3938. and consume arguments a bit unpredictably for an alias or script. But,
  3939. if you are ready to give up using old style options, you may resort to
  3940. using something like (a Bourne shell function here):
  3941. @smallexample
  3942. tar () @{ /usr/local/bin/tar --backup $*; @}
  3943. @end smallexample
  3944. @node Applications
  3945. @section Notable @command{tar} Usages
  3946. @UNREVISED
  3947. @FIXME{Using Unix file linking capability to recreate directory
  3948. structures---linking files into one subdirectory and then
  3949. @command{tar}ring that directory.}
  3950. @FIXME{Nice hairy example using absolute-names, newer, etc.}
  3951. @findex uuencode
  3952. You can easily use archive files to transport a group of files from
  3953. one system to another: put all relevant files into an archive on one
  3954. computer system, transfer the archive to another system, and extract
  3955. the contents there. The basic transfer medium might be magnetic tape,
  3956. Internet FTP, or even electronic mail (though you must encode the
  3957. archive with @command{uuencode} in order to transport it properly by
  3958. mail). Both machines do not have to use the same operating system, as
  3959. long as they both support the @command{tar} program.
  3960. For example, here is how you might copy a directory's contents from
  3961. one disk to another, while preserving the dates, modes, owners and
  3962. link-structure of all the files therein. In this case, the transfer
  3963. medium is a @dfn{pipe}, which is one a Unix redirection mechanism:
  3964. @smallexample
  3965. $ @kbd{(cd sourcedir; tar -cf - .) | (cd targetdir; tar -xf -)}
  3966. @end smallexample
  3967. @noindent
  3968. You can avoid subshells by using @option{-C} option:
  3969. @smallexample
  3970. $ @kbd{tar -C sourcedir -cf - . | tar -C targetdir -xf -}
  3971. @end smallexample
  3972. @noindent
  3973. The command also works using short option forms:
  3974. @smallexample
  3975. $ @kbd{(cd sourcedir; tar --create --file=- . ) \
  3976. | (cd targetdir; tar --extract --file=-)}
  3977. # Or:
  3978. $ @kbd{tar --directory sourcedir --create --file=- . ) \
  3979. | tar --directory targetdir --extract --file=-}
  3980. @end smallexample
  3981. @noindent
  3982. This is one of the easiest methods to transfer a @command{tar} archive.
  3983. @node looking ahead
  3984. @section Looking Ahead: The Rest of this Manual
  3985. You have now seen how to use all eight of the operations available to
  3986. @command{tar}, and a number of the possible options. The next chapter
  3987. explains how to choose and change file and archive names, how to use
  3988. files to store names of other files which you can then call as
  3989. arguments to @command{tar} (this can help you save time if you expect to
  3990. archive the same list of files a number of times), and so forth.
  3991. @FIXME{in case it's not obvious, i'm making this up in some sense
  3992. based on my limited memory of what the next chapter *really* does. i
  3993. just wanted to flesh out this final section a little bit so i'd
  3994. remember to stick it in here. :-)}
  3995. If there are too many files to conveniently list on the command line,
  3996. you can list the names in a file, and @command{tar} will read that file.
  3997. @xref{files}.
  3998. There are various ways of causing @command{tar} to skip over some files,
  3999. and not archive them. @xref{Choosing}.
  4000. @node Backups
  4001. @chapter Performing Backups and Restoring Files
  4002. @UNREVISED
  4003. @GNUTAR{} is distributed along with the scripts
  4004. which the Free Software Foundation uses for performing backups. There
  4005. is no corresponding scripts available yet for doing restoration of
  4006. files. Even if there is a good chance those scripts may be satisfying
  4007. to you, they are not the only scripts or methods available for doing
  4008. backups and restore. You may well create your own, or use more
  4009. sophisticated packages dedicated to that purpose.
  4010. Some users are enthusiastic about @code{Amanda} (The Advanced Maryland
  4011. Automatic Network Disk Archiver), a backup system developed by James
  4012. da Silva @file{jds@@cs.umd.edu} and available on many Unix systems.
  4013. This is free software, and it is available at these places:
  4014. @smallexample
  4015. http://www.cs.umd.edu/projects/amanda/amanda.html
  4016. ftp://ftp.cs.umd.edu/pub/amanda
  4017. @end smallexample
  4018. @FIXME{
  4019. Here is a possible plan for a future documentation about the backuping
  4020. scripts which are provided within the @GNUTAR{}
  4021. distribution.
  4022. @itemize @bullet
  4023. @item dumps
  4024. @itemize @minus
  4025. @item what are dumps
  4026. @item different levels of dumps
  4027. @itemize +
  4028. @item full dump = dump everything
  4029. @item level 1, level 2 dumps etc
  4030. A level @var{n} dump dumps everything changed since the last level
  4031. @var{n}-1 dump (?)
  4032. @end itemize
  4033. @item how to use scripts for dumps (ie, the concept)
  4034. @itemize +
  4035. @item scripts to run after editing backup specs (details)
  4036. @end itemize
  4037. @item Backup Specs, what is it.
  4038. @itemize +
  4039. @item how to customize
  4040. @item actual text of script [/sp/dump/backup-specs]
  4041. @end itemize
  4042. @item Problems
  4043. @itemize +
  4044. @item rsh doesn't work
  4045. @item rtape isn't installed
  4046. @item (others?)
  4047. @end itemize
  4048. @item the @option{--incremental} option of tar
  4049. @item tapes
  4050. @itemize +
  4051. @item write protection
  4052. @item types of media, different sizes and types, useful for different things
  4053. @item files and tape marks
  4054. one tape mark between files, two at end.
  4055. @item positioning the tape
  4056. MT writes two at end of write,
  4057. backspaces over one when writing again.
  4058. @end itemize
  4059. @end itemize
  4060. @end itemize
  4061. }
  4062. This chapter documents both the provided shell scripts and @command{tar}
  4063. options which are more specific to usage as a backup tool.
  4064. To @dfn{back up} a file system means to create archives that contain
  4065. all the files in that file system. Those archives can then be used to
  4066. restore any or all of those files (for instance if a disk crashes or a
  4067. file is accidentally deleted). File system @dfn{backups} are also
  4068. called @dfn{dumps}.
  4069. @menu
  4070. * Full Dumps:: Using @command{tar} to Perform Full Dumps
  4071. * Incremental Dumps:: Using @command{tar} to Perform Incremental Dumps
  4072. * Backup Levels:: Levels of Backups
  4073. * Backup Parameters:: Setting Parameters for Backups and Restoration
  4074. * Scripted Backups:: Using the Backup Scripts
  4075. * Scripted Restoration:: Using the Restore Script
  4076. @end menu
  4077. @node Full Dumps
  4078. @section Using @command{tar} to Perform Full Dumps
  4079. @UNREVISED
  4080. @cindex full dumps
  4081. @cindex dumps, full
  4082. @cindex corrupted archives
  4083. Full dumps should only be made when no other people or programs
  4084. are modifying files in the file system. If files are modified while
  4085. @command{tar} is making the backup, they may not be stored properly in
  4086. the archive, in which case you won't be able to restore them if you
  4087. have to. (Files not being modified are written with no trouble, and do
  4088. not corrupt the entire archive.)
  4089. You will want to use the @option{--label=@var{archive-label}}
  4090. (@option{-V @var{archive-label}}) option to give the archive a
  4091. volume label, so you can tell what this archive is even if the label
  4092. falls off the tape, or anything like that.
  4093. Unless the file system you are dumping is guaranteed to fit on
  4094. one volume, you will need to use the @option{--multi-volume} (@option{-M}) option.
  4095. Make sure you have enough tapes on hand to complete the backup.
  4096. If you want to dump each file system separately you will need to use
  4097. the @option{--one-file-system} option to prevent
  4098. @command{tar} from crossing file system boundaries when storing
  4099. (sub)directories.
  4100. The @option{--incremental} (@option{-G}) (@pxref{Incremental Dumps})
  4101. option is not needed, since this is a complete copy of everything in
  4102. the file system, and a full restore from this backup would only be
  4103. done onto a completely
  4104. empty disk.
  4105. Unless you are in a hurry, and trust the @command{tar} program (and your
  4106. tapes), it is a good idea to use the @option{--verify} (@option{-W})
  4107. option, to make sure your files really made it onto the dump properly.
  4108. This will also detect cases where the file was modified while (or just
  4109. after) it was being archived. Not all media (notably cartridge tapes)
  4110. are capable of being verified, unfortunately.
  4111. @node Incremental Dumps
  4112. @section Using @command{tar} to Perform Incremental Dumps
  4113. @dfn{Incremental backup} is a special form of @GNUTAR{} archive that
  4114. stores additional metadata so that exact state of the file system
  4115. can be restored when extracting the archive.
  4116. @GNUTAR{} currently offers two options for handling incremental
  4117. backups: @option{--listed-incremental=@var{snapshot-file}} (@option{-g
  4118. @var{snapshot-file}}) and @option{--incremental} (@option{-G}).
  4119. @opindex listed-incremental
  4120. The option @option{--listed-incremental} instructs tar to operate on
  4121. an incremental archive with additional metadata stored in a standalone
  4122. file, called a @dfn{snapshot file}. The purpose of this file is to help
  4123. determine which files have been changed, added or deleted since the
  4124. last backup, so that the next incremental backup will contain only
  4125. modified files. The name of the snapshot file is given as an argument
  4126. to the option:
  4127. @table @option
  4128. @item --listed-incremental=@var{file}
  4129. @itemx -g @var{file}
  4130. Handle incremental backups with snapshot data in @var{file}.
  4131. @end table
  4132. To create an incremental backup, you would use
  4133. @option{--listed-incremental} together with @option{--create}
  4134. (@pxref{create}). For example:
  4135. @smallexample
  4136. $ @kbd{tar --create \
  4137. --file=archive.1.tar \
  4138. --listed-incremental=/var/log/usr.snar \
  4139. /usr}
  4140. @end smallexample
  4141. This will create in @file{archive.1.tar} an incremental backup of
  4142. the @file{/usr} file system, storing additional metadata in the file
  4143. @file{/var/log/usr.snar}. If this file does not exist, it will be
  4144. created. The created archive will then be a @dfn{level 0 backup};
  4145. please see the next section for more on backup levels.
  4146. Otherwise, if the file @file{/var/log/usr.snar} exists, it
  4147. determines which files are modified. In this case only these files will be
  4148. stored in the archive. Suppose, for example, that after running the
  4149. above command, you delete file @file{/usr/doc/old} and create
  4150. directory @file{/usr/local/db} with the following contents:
  4151. @smallexample
  4152. $ @kbd{ls /usr/local/db}
  4153. /usr/local/db/data
  4154. /usr/local/db/index
  4155. @end smallexample
  4156. Some time later you create another incremental backup. You will
  4157. then see:
  4158. @smallexample
  4159. $ @kbd{tar --create \
  4160. --file=archive.2.tar \
  4161. --listed-incremental=/var/log/usr.snar \
  4162. /usr}
  4163. tar: usr/local/db: Directory is new
  4164. usr/local/db/
  4165. usr/local/db/data
  4166. usr/local/db/index
  4167. @end smallexample
  4168. @noindent
  4169. The created archive @file{archive.2.tar} will contain only these
  4170. three members. This archive is called a @dfn{level 1 backup}. Notice
  4171. that @file{/var/log/usr.snar} will be updated with the new data, so if
  4172. you plan to create more @samp{level 1} backups, it is necessary to
  4173. create a working copy of the snapshot file before running
  4174. @command{tar}. The above example will then be modified as follows:
  4175. @smallexample
  4176. $ @kbd{cp /var/log/usr.snar /var/log/usr.snar-1}
  4177. $ @kbd{tar --create \
  4178. --file=archive.2.tar \
  4179. --listed-incremental=/var/log/usr.snar-1 \
  4180. /usr}
  4181. @end smallexample
  4182. Incremental dumps depend crucially on time stamps, so the results are
  4183. unreliable if you modify a file's time stamps during dumping (e.g.,
  4184. with the @option{--atime-preserve=replace} option), or if you set the clock
  4185. backwards.
  4186. Metadata stored in snapshot files include device numbers, which,
  4187. obviously is supposed to be a non-volatile value. However, it turns
  4188. out that NFS devices have undependable values when an automounter
  4189. gets in the picture. This can lead to a great deal of spurious
  4190. redumping in incremental dumps, so it is somewhat useless to compare
  4191. two NFS devices numbers over time. The solution implemented currently
  4192. is to considers all NFS devices as being equal when it comes to
  4193. comparing directories; this is fairly gross, but there does not seem
  4194. to be a better way to go.
  4195. Note that incremental archives use @command{tar} extensions and may
  4196. not be readable by non-@acronym{GNU} versions of the @command{tar} program.
  4197. @opindex listed-incremental, using with @option{--extract}
  4198. @opindex extract, using with @option{--listed-incremental}
  4199. To extract from the incremental dumps, use
  4200. @option{--listed-incremental} together with @option{--extract}
  4201. option (@pxref{extracting files}). In this case, @command{tar} does
  4202. not need to access snapshot file, since all the data necessary for
  4203. extraction are stored in the archive itself. So, when extracting, you
  4204. can give whatever argument to @option{--listed-incremental}, the usual
  4205. practice is to use @option{--listed-incremental=/dev/null}.
  4206. Alternatively, you can use @option{--incremental}, which needs no
  4207. arguments. In general, @option{--incremental} (@option{-G}) can be
  4208. used as a shortcut for @option{--listed-incremental} when listing or
  4209. extracting incremental backups (for more information, regarding this
  4210. option, @pxref{incremental-op}).
  4211. When extracting from the incremental backup @GNUTAR{} attempts to
  4212. restore the exact state the file system had when the archive was
  4213. created. In particular, it will @emph{delete} those files in the file
  4214. system that did not exist in their directories when the archive was
  4215. created. If you have created several levels of incremental files,
  4216. then in order to restore the exact contents the file system had when
  4217. the last level was created, you will need to restore from all backups
  4218. in turn. Continuing our example, to restore the state of @file{/usr}
  4219. file system, one would do@footnote{Notice, that since both archives
  4220. were created withouth @option{-P} option (@pxref{absolute}), these
  4221. commands should be run from the root file system.}:
  4222. @smallexample
  4223. $ @kbd{tar --extract \
  4224. --listed-incremental=/dev/null \
  4225. --file archive.1.tar}
  4226. $ @kbd{tar --extract \
  4227. --listed-incremental=/dev/null \
  4228. --file archive.2.tar}
  4229. @end smallexample
  4230. To list the contents of an incremental archive, use @option{--list}
  4231. (@pxref{list}), as usual. To obtain more information about the
  4232. archive, use @option{--listed-incremental} or @option{--incremental}
  4233. combined with two @option{--verbose} options@footnote{Two
  4234. @option{--verbose} options were selected to avoid breaking usual
  4235. verbose listing output (@option{--list --verbose}) when using in
  4236. scripts.
  4237. @opindex incremental, using with @option{--list}
  4238. @opindex listed-incremental, using with @option{--list}
  4239. @opindex list, using with @option{--incremental}
  4240. @opindex list, using with @option{--listed-incremental}
  4241. Versions of @GNUTAR{} up to 1.15.1 used to dump verbatim binary
  4242. contents of the DUMPDIR header (with terminating nulls) when
  4243. @option{--incremental} or @option{--listed-incremental} option was
  4244. given, no matter what the verbosity level. This behavior, and,
  4245. especially, the binary output it produced were considered incovenient
  4246. and were changed in version 1.16}:
  4247. @smallexample
  4248. @kbd{tar --list --incremental --verbose --verbose archive.tar}
  4249. @end smallexample
  4250. This command will print, for each directory in the archive, the list
  4251. of files in that directory at the time the archive was created. This
  4252. information is put out in a format which is both human-readable and
  4253. unambiguous for a program: each file name is printed as
  4254. @smallexample
  4255. @var{x} @var{file}
  4256. @end smallexample
  4257. @noindent
  4258. where @var{x} is a letter describing the status of the file: @samp{Y}
  4259. if the file is present in the archive, @samp{N} if the file is not
  4260. included in the archive, or a @samp{D} if the file is a directory (and
  4261. is included in the archive). @xref{Dumpdir}, for the detailed
  4262. description of dumpdirs and status codes. Each such
  4263. line is terminated by a newline character. The last line is followed
  4264. by an additional newline to indicate the end of the data.
  4265. @anchor{incremental-op}The option @option{--incremental} (@option{-G})
  4266. gives the same behavior as @option{--listed-incremental} when used
  4267. with @option{--list} and @option{--extract} options. When used with
  4268. @option{--create} option, it creates an incremental archive without
  4269. creating snapshot file. Thus, it is impossible to create several
  4270. levels of incremental backups with @option{--incremental} option.
  4271. @node Backup Levels
  4272. @section Levels of Backups
  4273. An archive containing all the files in the file system is called a
  4274. @dfn{full backup} or @dfn{full dump}. You could insure your data by
  4275. creating a full dump every day. This strategy, however, would waste a
  4276. substantial amount of archive media and user time, as unchanged files
  4277. are daily re-archived.
  4278. It is more efficient to do a full dump only occasionally. To back up
  4279. files between full dumps, you can use @dfn{incremental dumps}. A @dfn{level
  4280. one} dump archives all the files that have changed since the last full
  4281. dump.
  4282. A typical dump strategy would be to perform a full dump once a week,
  4283. and a level one dump once a day. This means some versions of files
  4284. will in fact be archived more than once, but this dump strategy makes
  4285. it possible to restore a file system to within one day of accuracy by
  4286. only extracting two archives---the last weekly (full) dump and the
  4287. last daily (level one) dump. The only information lost would be in
  4288. files changed or created since the last daily backup. (Doing dumps
  4289. more than once a day is usually not worth the trouble).
  4290. @GNUTAR{} comes with scripts you can use to do full
  4291. and level-one (actually, even level-two and so on) dumps. Using
  4292. scripts (shell programs) to perform backups and restoration is a
  4293. convenient and reliable alternative to typing out file name lists
  4294. and @command{tar} commands by hand.
  4295. Before you use these scripts, you need to edit the file
  4296. @file{backup-specs}, which specifies parameters used by the backup
  4297. scripts and by the restore script. This file is usually located
  4298. in @file{/etc/backup} directory. @xref{Backup Parameters}, for its
  4299. detailed description. Once the backup parameters are set, you can
  4300. perform backups or restoration by running the appropriate script.
  4301. The name of the backup script is @code{backup}. The name of the
  4302. restore script is @code{restore}. The following sections describe
  4303. their use in detail.
  4304. @emph{Please Note:} The backup and restoration scripts are
  4305. designed to be used together. While it is possible to restore files by
  4306. hand from an archive which was created using a backup script, and to create
  4307. an archive by hand which could then be extracted using the restore script,
  4308. it is easier to use the scripts. @xref{Incremental Dumps}, before
  4309. making such an attempt.
  4310. @node Backup Parameters
  4311. @section Setting Parameters for Backups and Restoration
  4312. The file @file{backup-specs} specifies backup parameters for the
  4313. backup and restoration scripts provided with @command{tar}. You must
  4314. edit @file{backup-specs} to fit your system configuration and schedule
  4315. before using these scripts.
  4316. Syntactically, @file{backup-specs} is a shell script, containing
  4317. mainly variable assignments. However, any valid shell construct
  4318. is allowed in this file. Particularly, you may wish to define
  4319. functions within that script (e.g., see @code{RESTORE_BEGIN} below).
  4320. For more information about shell script syntax, please refer to
  4321. @url{http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#ta
  4322. g_02, the definition of the Shell Command Language}. See also
  4323. @ref{Top,,Bash Features,bashref,Bash Reference Manual}.
  4324. The shell variables controlling behavior of @code{backup} and
  4325. @code{restore} are described in the following subsections.
  4326. @menu
  4327. * General-Purpose Variables::
  4328. * Magnetic Tape Control::
  4329. * User Hooks::
  4330. * backup-specs example:: An Example Text of @file{Backup-specs}
  4331. @end menu
  4332. @node General-Purpose Variables
  4333. @subsection General-Purpose Variables
  4334. @defvr {Backup variable} ADMINISTRATOR
  4335. The user name of the backup administrator. @code{Backup} scripts
  4336. sends a backup report to this address.
  4337. @end defvr
  4338. @defvr {Backup variable} BACKUP_HOUR
  4339. The hour at which the backups are done. This can be a number from 0
  4340. to 23, or the time specification in form @var{hours}:@var{minutes},
  4341. or the string @samp{now}.
  4342. This variable is used by @code{backup}. Its value may be overridden
  4343. using @option{--time} option (@pxref{Scripted Backups}).
  4344. @end defvr
  4345. @defvr {Backup variable} TAPE_FILE
  4346. The device @command{tar} writes the archive to. If @var{TAPE_FILE}
  4347. is a remote archive (@pxref{remote-dev}), backup script will suppose
  4348. that your @command{mt} is able to access remote devices. If @var{RSH}
  4349. (@pxref{RSH}) is set, @option{--rsh-command} option will be added to
  4350. invocations of @command{mt}.
  4351. @end defvr
  4352. @defvr {Backup variable} BLOCKING
  4353. The blocking factor @command{tar} will use when writing the dump archive.
  4354. @xref{Blocking Factor}.
  4355. @end defvr
  4356. @defvr {Backup variable} BACKUP_DIRS
  4357. A list of file systems to be dumped (for @code{backup}), or restored
  4358. (for @code{restore}). You can include any directory
  4359. name in the list --- subdirectories on that file system will be
  4360. included, regardless of how they may look to other networked machines.
  4361. Subdirectories on other file systems will be ignored.
  4362. The host name specifies which host to run @command{tar} on, and should
  4363. normally be the host that actually contains the file system. However,
  4364. the host machine must have @GNUTAR{} installed, and
  4365. must be able to access the directory containing the backup scripts and
  4366. their support files using the same file name that is used on the
  4367. machine where the scripts are run (ie. what @command{pwd} will print
  4368. when in that directory on that machine). If the host that contains
  4369. the file system does not have this capability, you can specify another
  4370. host as long as it can access the file system through NFS.
  4371. If the list of file systems is very long you may wish to put it
  4372. in a separate file. This file is usually named
  4373. @file{/etc/backup/dirs}, but this name may be overridden in
  4374. @file{backup-specs} using @code{DIRLIST} variable.
  4375. @end defvr
  4376. @defvr {Backup variable} DIRLIST
  4377. A path to the file containing the list of the file systems to backup
  4378. or restore. By default it is @file{/etc/backup/dirs}.
  4379. @end defvr
  4380. @defvr {Backup variable} BACKUP_FILES
  4381. A list of individual files to be dumped (for @code{backup}), or restored
  4382. (for @code{restore}). These should be accessible from the machine on
  4383. which the backup script is run.
  4384. If the list of file systems is very long you may wish to store it
  4385. in a separate file. This file is usually named
  4386. @file{/etc/backup/files}, but this name may be overridden in
  4387. @file{backup-specs} using @code{FILELIST} variable.
  4388. @end defvr
  4389. @defvr {Backup variable} FILELIST
  4390. A path to the file containing the list of the individual files to backup
  4391. or restore. By default it is @file{/etc/backup/files}.
  4392. @end defvr
  4393. @defvr {Backup variable} MT
  4394. Full file name of @command{mt} binary.
  4395. @end defvr
  4396. @defvr {Backup variable} RSH
  4397. @anchor{RSH}
  4398. Full file name of @command{rsh} binary or its equivalent. You may wish to
  4399. set it to @code{ssh}, to improve security. In this case you will have
  4400. to use public key authentication.
  4401. @end defvr
  4402. @defvr {Backup variable} RSH_COMMAND
  4403. Full file name of @command{rsh} binary on remote mashines. This will
  4404. be passed via @option{--rsh-command} option to the remote invocation
  4405. of @GNUTAR{}.
  4406. @end defvr
  4407. @defvr {Backup variable} VOLNO_FILE
  4408. Name of temporary file to hold volume numbers. This needs to be accessible
  4409. by all the machines which have file systems to be dumped.
  4410. @end defvr
  4411. @defvr {Backup variable} XLIST
  4412. Name of @dfn{exclude file list}. An @dfn{exclude file list} is a file
  4413. located on the remote machine and containing the list of files to
  4414. be excluded from the backup. Exclude file lists are searched in
  4415. /etc/tar-backup directory. A common use for exclude file lists
  4416. is to exclude files containing security-sensitive information
  4417. (e.g., @file{/etc/shadow} from backups).
  4418. This variable affects only @code{backup}.
  4419. @end defvr
  4420. @defvr {Backup variable} SLEEP_TIME
  4421. Time to sleep between dumps of any two successive file systems
  4422. This variable affects only @code{backup}.
  4423. @end defvr
  4424. @defvr {Backup variable} DUMP_REMIND_SCRIPT
  4425. Script to be run when it's time to insert a new tape in for the next
  4426. volume. Administrators may want to tailor this script for their site.
  4427. If this variable isn't set, @GNUTAR{} will display its built-in
  4428. prompt, and will expect confirmation from the console.
  4429. The built-in prompt for POSIX locale is:
  4430. @smallexample
  4431. Prepare volume #@var{n} for `@var{archive}' and hit return:
  4432. @end smallexample
  4433. @noindent
  4434. where @var{n} is the ordinal number of the volume to be created and
  4435. @var{archive} is archive file or device name.
  4436. If you run @GNUTAR{} under a different locale, the translation of
  4437. the above prompt to the locale's language will be used.
  4438. @end defvr
  4439. @defvr {Backup variable} SLEEP_MESSAGE
  4440. Message to display on the terminal while waiting for dump time. Usually
  4441. this will just be some literal text.
  4442. @end defvr
  4443. @defvr {Backup variable} TAR
  4444. Full file name of the @GNUTAR{} executable. If this is not set, backup
  4445. scripts will search @command{tar} in the current shell path.
  4446. @end defvr
  4447. @node Magnetic Tape Control
  4448. @subsection Magnetic Tape Control
  4449. Backup scripts access tape device using special @dfn{hook functions}.
  4450. These functions take a single argument -- the name of the tape
  4451. device. Their names are kept in the following variables:
  4452. @defvr {Backup variable} MT_BEGIN
  4453. The name of @dfn{begin} function. This function is called before
  4454. accessing the drive. By default it retensions the tape:
  4455. @smallexample
  4456. MT_BEGIN=mt_begin
  4457. mt_begin() @{
  4458. mt -f "$1" retension
  4459. @}
  4460. @end smallexample
  4461. @end defvr
  4462. @defvr {Backup variable} MT_REWIND
  4463. The name of @dfn{rewind} function. The default definition is as
  4464. follows:
  4465. @smallexample
  4466. MT_REWIND=mt_rewind
  4467. mt_rewind() @{
  4468. mt -f "$1" rewind
  4469. @}
  4470. @end smallexample
  4471. @end defvr
  4472. @defvr {Backup variable} MT_OFFLINE
  4473. The name of the function switching the tape off line. By default
  4474. it is defined as follows:
  4475. @smallexample
  4476. MT_OFFLINE=mt_offline
  4477. mt_offline() @{
  4478. mt -f "$1" offl
  4479. @}
  4480. @end smallexample
  4481. @end defvr
  4482. @defvr {Backup variable} MT_STATUS
  4483. The name of the function used to obtain the status of the archive device,
  4484. including error count. Default definition:
  4485. @smallexample
  4486. MT_STATUS=mt_status
  4487. mt_status() @{
  4488. mt -f "$1" status
  4489. @}
  4490. @end smallexample
  4491. @end defvr
  4492. @node User Hooks
  4493. @subsection User Hooks
  4494. @dfn{User hooks} are shell functions executed before and after
  4495. each @command{tar} invocation. Thus, there are @dfn{backup
  4496. hooks}, which are executed before and after dumping each file
  4497. system, and @dfn{restore hooks}, executed before and
  4498. after restoring a file system. Each user hook is a shell function
  4499. taking four arguments:
  4500. @deffn {User Hook Function} hook @var{level} @var{host} @var{fs} @var{fsname}
  4501. Its arguments are:
  4502. @table @var
  4503. @item level
  4504. Current backup or restore level.
  4505. @item host
  4506. Name or IP address of the host machine being dumped or restored.
  4507. @item fs
  4508. Full path name to the file system being dumped or restored.
  4509. @item fsname
  4510. File system name with directory separators replaced with colons. This
  4511. is useful, e.g., for creating unique files.
  4512. @end table
  4513. @end deffn
  4514. Following variables keep the names of user hook functions
  4515. @defvr {Backup variable} DUMP_BEGIN
  4516. Dump begin function. It is executed before dumping the file system.
  4517. @end defvr
  4518. @defvr {Backup variable} DUMP_END
  4519. Executed after dumping the file system.
  4520. @end defvr
  4521. @defvr {Backup variable} RESTORE_BEGIN
  4522. Executed before restoring the file system.
  4523. @end defvr
  4524. @defvr {Backup variable} RESTORE_END
  4525. Executed after restoring the file system.
  4526. @end defvr
  4527. @node backup-specs example
  4528. @subsection An Example Text of @file{Backup-specs}
  4529. The following is an example of @file{backup-specs}:
  4530. @smallexample
  4531. # site-specific parameters for file system backup.
  4532. ADMINISTRATOR=friedman
  4533. BACKUP_HOUR=1
  4534. TAPE_FILE=/dev/nrsmt0
  4535. # Use @code{ssh} instead of the less secure @code{rsh}
  4536. RSH=/usr/bin/ssh
  4537. RSH_COMMAND=/usr/bin/ssh
  4538. # Override MT_STATUS function:
  4539. my_status() @{
  4540. mts -t $TAPE_FILE
  4541. @}
  4542. MT_STATUS=my_status
  4543. # Disable MT_OFFLINE function
  4544. MT_OFFLINE=:
  4545. BLOCKING=124
  4546. BACKUP_DIRS="
  4547. albert:/fs/fsf
  4548. apple-gunkies:/gd
  4549. albert:/fs/gd2
  4550. albert:/fs/gp
  4551. geech:/usr/jla
  4552. churchy:/usr/roland
  4553. albert:/
  4554. albert:/usr
  4555. apple-gunkies:/
  4556. apple-gunkies:/usr
  4557. gnu:/hack
  4558. gnu:/u
  4559. apple-gunkies:/com/mailer/gnu
  4560. apple-gunkies:/com/archive/gnu"
  4561. BACKUP_FILES="/com/mailer/aliases /com/mailer/league*[a-z]"
  4562. @end smallexample
  4563. @node Scripted Backups
  4564. @section Using the Backup Scripts
  4565. The syntax for running a backup script is:
  4566. @smallexample
  4567. backup --level=@var{level} --time=@var{time}
  4568. @end smallexample
  4569. The @option{level} option requests the dump level. Thus, to produce
  4570. a full dump, specify @code{--level=0} (this is the default, so
  4571. @option{--level} may be omitted if its value is @code{0}).
  4572. @footnote{For backward compatibility, the @code{backup} will also
  4573. try to deduce the requested dump level from the name of the
  4574. script itself. If the name consists of a string @samp{level-}
  4575. followed by a single decimal digit, that digit is taken as
  4576. the dump level number. Thus, you may create a link from @code{backup}
  4577. to @code{level-1} and then run @code{level-1} whenever you need to
  4578. create a level one dump.}
  4579. The @option{--time} option determines when should the backup be
  4580. run. @var{Time} may take three forms:
  4581. @table @asis
  4582. @item @var{hh}:@var{mm}
  4583. The dump must be run at @var{hh} hours @var{mm} minutes.
  4584. @item @var{hh}
  4585. The dump must be run at @var{hh} hours
  4586. @item now
  4587. The dump must be run immediately.
  4588. @end table
  4589. You should start a script with a tape or disk mounted. Once you
  4590. start a script, it prompts you for new tapes or disks as it
  4591. needs them. Media volumes don't have to correspond to archive
  4592. files --- a multi-volume archive can be started in the middle of a
  4593. tape that already contains the end of another multi-volume archive.
  4594. The @code{restore} script prompts for media by its archive volume,
  4595. so to avoid an error message you should keep track of which tape
  4596. (or disk) contains which volume of the archive (@pxref{Scripted
  4597. Restoration}).
  4598. The backup scripts write two files on the file system. The first is a
  4599. record file in @file{/etc/tar-backup/}, which is used by the scripts
  4600. to store and retrieve information about which files were dumped. This
  4601. file is not meant to be read by humans, and should not be deleted by
  4602. them. @xref{Snapshot Files}, for a more detailed explanation of this
  4603. file.
  4604. The second file is a log file containing the names of the file systems
  4605. and files dumped, what time the backup was made, and any error
  4606. messages that were generated, as well as how much space was left in
  4607. the media volume after the last volume of the archive was written.
  4608. You should check this log file after every backup. The file name is
  4609. @file{log-@var{mm-dd-yyyy}-level-@var{n}}, where @var{mm-dd-yyyy}
  4610. represents current date, and @var{n} represents current dump level number.
  4611. The script also prints the name of each system being dumped to the
  4612. standard output.
  4613. Following is the full list of options accepted by @code{backup}
  4614. script:
  4615. @table @option
  4616. @item -l @var{level}
  4617. @itemx --level=@var{level}
  4618. Do backup level @var{level} (default 0).
  4619. @item -f
  4620. @itemx --force
  4621. Force backup even if today's log file already exists.
  4622. @item -v[@var{level}]
  4623. @itemx --verbose[=@var{level}]
  4624. Set verbosity level. The higher the level is, the more debugging
  4625. information will be output during execution. Devault @var{level}
  4626. is 100, which means the highest debugging level.
  4627. @item -t @var{start-time}
  4628. @itemx --time=@var{start-time}
  4629. Wait till @var{time}, then do backup.
  4630. @item -h
  4631. @itemx --help
  4632. Display short help message and exit.
  4633. @item -V
  4634. @itemx --version
  4635. Display information about the program's name, version, origin and legal
  4636. status, all on standard output, and then exit successfully.
  4637. @end table
  4638. @node Scripted Restoration
  4639. @section Using the Restore Script
  4640. To restore files that were archived using a scripted backup, use the
  4641. @code{restore} script. Its usage is quite straightforward. In the
  4642. simplest form, invoke @code{restore --all}, it will
  4643. then restore all the file systems and files specified in
  4644. @file{backup-specs} (@pxref{General-Purpose Variables,BACKUP_DIRS}).
  4645. You may select the file systems (and/or files) to restore by
  4646. giving @code{restore} list of @dfn{patterns} in its command
  4647. line. For example, running
  4648. @smallexample
  4649. restore 'albert:*'
  4650. @end smallexample
  4651. @noindent
  4652. will restore all file systems on the machine @samp{albert}. A more
  4653. complicated example:
  4654. @smallexample
  4655. restore 'albert:*' '*:/var'
  4656. @end smallexample
  4657. @noindent
  4658. This command will restore all file systems on the machine @samp{albert}
  4659. as well as @file{/var} file system on all machines.
  4660. By default @code{restore} will start restoring files from the lowest
  4661. available dump level (usually zero) and will continue through
  4662. all available dump levels. There may be situations where such a
  4663. thorough restore is not necessary. For example, you may wish to
  4664. restore only files from the recent level one backup. To do so,
  4665. use @option{--level} option, as shown in the example below:
  4666. @smallexample
  4667. restore --level=1
  4668. @end smallexample
  4669. The full list of options accepted by @code{restore} follows:
  4670. @table @option
  4671. @item -a
  4672. @itemx --all
  4673. Restore all file systems and files specified in @file{backup-specs}
  4674. @item -l @var{level}
  4675. @itemx --level=@var{level}
  4676. Start restoring from the given backup level, instead of the default 0.
  4677. @item -v[@var{level}]
  4678. @itemx --verbose[=@var{level}]
  4679. Set verbosity level. The higher the level is, the more debugging
  4680. information will be output during execution. Devault @var{level}
  4681. is 100, which means the highest debugging level.
  4682. @item -h
  4683. @itemx --help
  4684. Display short help message and exit.
  4685. @item -V
  4686. @itemx --version
  4687. Display information about the program's name, version, origin and legal
  4688. status, all on standard output, and then exit successfully.
  4689. @end table
  4690. You should start the restore script with the media containing the
  4691. first volume of the archive mounted. The script will prompt for other
  4692. volumes as they are needed. If the archive is on tape, you don't need
  4693. to rewind the tape to to its beginning---if the tape head is
  4694. positioned past the beginning of the archive, the script will rewind
  4695. the tape as needed. @FIXME-xref{Media, for a discussion of tape
  4696. positioning.}
  4697. @quotation
  4698. @strong{Warning:} The script will delete files from the active file
  4699. system if they were not in the file system when the archive was made.
  4700. @end quotation
  4701. @xref{Incremental Dumps}, for an explanation of how the script makes
  4702. that determination.
  4703. @node Choosing
  4704. @chapter Choosing Files and Names for @command{tar}
  4705. @UNREVISED
  4706. Certain options to @command{tar} enable you to specify a name for your
  4707. archive. Other options let you decide which files to include or exclude
  4708. from the archive, based on when or whether files were modified, whether
  4709. the file names do or don't match specified patterns, or whether files
  4710. are in specified directories.
  4711. This chapter discusses these options in detail.
  4712. @menu
  4713. * file:: Choosing the Archive's Name
  4714. * Selecting Archive Members::
  4715. * files:: Reading Names from a File
  4716. * exclude:: Excluding Some Files
  4717. * wildcards:: Wildcards Patterns and Matching
  4718. * quoting styles:: Ways of Quoting Special Characters in Names
  4719. * transform:: Modifying File and Member Names
  4720. * after:: Operating Only on New Files
  4721. * recurse:: Descending into Directories
  4722. * one:: Crossing File System Boundaries
  4723. @end menu
  4724. @node file
  4725. @section Choosing and Naming Archive Files
  4726. @UNREVISED
  4727. @cindex Naming an archive
  4728. @cindex Archive Name
  4729. @cindex Choosing an archive file
  4730. @cindex Where is the archive?
  4731. By default, @command{tar} uses an archive file name that was compiled when
  4732. it was built on the system; usually this name refers to some physical
  4733. tape drive on the machine. However, the person who installed @command{tar}
  4734. on the system may not have set the default to a meaningful value as far as
  4735. most users are concerned. As a result, you will usually want to tell
  4736. @command{tar} where to find (or create) the archive. The
  4737. @option{--file=@var{archive-name}} (@option{-f @var{archive-name}})
  4738. option allows you to either specify or name a file to use as the archive
  4739. instead of the default archive file location.
  4740. @table @option
  4741. @opindex file, short description
  4742. @item --file=@var{archive-name}
  4743. @itemx -f @var{archive-name}
  4744. Name the archive to create or operate on. Use in conjunction with
  4745. any operation.
  4746. @end table
  4747. For example, in this @command{tar} command,
  4748. @smallexample
  4749. $ @kbd{tar -cvf collection.tar blues folk jazz}
  4750. @end smallexample
  4751. @noindent
  4752. @file{collection.tar} is the name of the archive. It must directly
  4753. follow the @option{-f} option, since whatever directly follows @option{-f}
  4754. @emph{will} end up naming the archive. If you neglect to specify an
  4755. archive name, you may end up overwriting a file in the working directory
  4756. with the archive you create since @command{tar} will use this file's name
  4757. for the archive name.
  4758. An archive can be saved as a file in the file system, sent through a
  4759. pipe or over a network, or written to an I/O device such as a tape,
  4760. floppy disk, or CD write drive.
  4761. @cindex Writing new archives
  4762. @cindex Archive creation
  4763. If you do not name the archive, @command{tar} uses the value of the
  4764. environment variable @env{TAPE} as the file name for the archive. If
  4765. that is not available, @command{tar} uses a default, compiled-in archive
  4766. name, usually that for tape unit zero (ie. @file{/dev/tu00}).
  4767. @cindex Standard input and output
  4768. @cindex tar to standard input and output
  4769. If you use @file{-} as an @var{archive-name}, @command{tar} reads the
  4770. archive from standard input (when listing or extracting files), or
  4771. writes it to standard output (when creating an archive). If you use
  4772. @file{-} as an @var{archive-name} when modifying an archive,
  4773. @command{tar} reads the original archive from its standard input and
  4774. writes the entire new archive to its standard output.
  4775. The following example is a convenient way of copying directory
  4776. hierarchy from @file{sourcedir} to @file{targetdir}.
  4777. @smallexample
  4778. $ @kbd{(cd sourcedir; tar -cf - .) | (cd targetdir; tar -xpf -)}
  4779. @end smallexample
  4780. The @option{-C} option allows to avoid using subshells:
  4781. @smallexample
  4782. $ @kbd{tar -C sourcedir -cf - . | tar -C targetdir -xpf -}
  4783. @end smallexample
  4784. In both examples above, the leftmost @command{tar} invocation archives
  4785. the contents of @file{sourcedir} to the standard output, while the
  4786. rightmost one reads this archive from its standard input and
  4787. extracts it. The @option{-p} option tells it to restore permissions
  4788. of the extracted files.
  4789. @cindex Remote devices
  4790. @cindex tar to a remote device
  4791. @anchor{remote-dev}
  4792. To specify an archive file on a device attached to a remote machine,
  4793. use the following:
  4794. @smallexample
  4795. @kbd{--file=@var{hostname}:/@var{dev}/@var{file-name}}
  4796. @end smallexample
  4797. @noindent
  4798. @command{tar} will complete the remote connection, if possible, and
  4799. prompt you for a username and password. If you use
  4800. @option{--file=@@@var{hostname}:/@var{dev}/@var{file-name}}, @command{tar}
  4801. will complete the remote connection, if possible, using your username
  4802. as the username on the remote machine.
  4803. @cindex Local and remote archives
  4804. @anchor{local and remote archives}
  4805. If the archive file name includes a colon (@samp{:}), then it is assumed
  4806. to be a file on another machine. If the archive file is
  4807. @samp{@var{user}@@@var{host}:@var{file}}, then @var{file} is used on the
  4808. host @var{host}. The remote host is accessed using the @command{rsh}
  4809. program, with a username of @var{user}. If the username is omitted
  4810. (along with the @samp{@@} sign), then your user name will be used.
  4811. (This is the normal @command{rsh} behavior.) It is necessary for the
  4812. remote machine, in addition to permitting your @command{rsh} access, to
  4813. have the @file{rmt} program installed (This command is included in
  4814. the @GNUTAR{} distribution and by default is installed under
  4815. @file{@var{prefix}/libexec/rmt}, were @var{prefix} means your
  4816. installation prefix). If you need to use a file whose name includes a
  4817. colon, then the remote tape drive behavior
  4818. can be inhibited by using the @option{--force-local} option.
  4819. When the archive is being created to @file{/dev/null}, @GNUTAR{}
  4820. tries to minimize input and output operations. The Amanda backup
  4821. system, when used with @GNUTAR{}, has an initial sizing pass which
  4822. uses this feature.
  4823. @node Selecting Archive Members
  4824. @section Selecting Archive Members
  4825. @cindex Specifying files to act on
  4826. @cindex Specifying archive members
  4827. @dfn{File Name arguments} specify which files in the file system
  4828. @command{tar} operates on, when creating or adding to an archive, or which
  4829. archive members @command{tar} operates on, when reading or deleting from
  4830. an archive. @xref{Operations}.
  4831. To specify file names, you can include them as the last arguments on
  4832. the command line, as follows:
  4833. @smallexample
  4834. @kbd{tar} @var{operation} [@var{option1} @var{option2} @dots{}] [@var{file name-1} @var{file name-2} @dots{}]
  4835. @end smallexample
  4836. If a file name begins with dash (@samp{-}), precede it with
  4837. @option{--add-file} option to prevent it from being treated as an
  4838. option.
  4839. If you specify a directory name as a file name argument, all the files
  4840. in that directory are operated on by @command{tar}.
  4841. If you do not specify files, @command{tar} behavior differs depending
  4842. on the operation mode as described below:
  4843. When @command{tar} is invoked with @option{--create} (@option{-c}),
  4844. @command{tar} will stop immediately, reporting the following:
  4845. @smallexample
  4846. @group
  4847. $ @kbd{tar cf a.tar}
  4848. tar: Cowardly refusing to create an empty archive
  4849. Try `tar --help' or `tar --usage' for more information.
  4850. @end group
  4851. @end smallexample
  4852. If you specify either @option{--list} (@option{-t}) or
  4853. @option{--extract} (@option{--get}, @option{-x}), @command{tar}
  4854. operates on all the archive members in the archive.
  4855. If run with @option{--diff} option, tar will compare the archive with
  4856. the contents of the current working directory.
  4857. If you specify any other operation, @command{tar} does nothing.
  4858. By default, @command{tar} takes file names from the command line. However,
  4859. there are other ways to specify file or member names, or to modify the
  4860. manner in which @command{tar} selects the files or members upon which to
  4861. operate. In general, these methods work both for specifying the names
  4862. of files and archive members.
  4863. @node files
  4864. @section Reading Names from a File
  4865. @cindex Reading file names from a file
  4866. @cindex Lists of file names
  4867. @cindex File Name arguments, alternatives
  4868. Instead of giving the names of files or archive members on the command
  4869. line, you can put the names into a file, and then use the
  4870. @option{--files-from=@var{file-of-names}} (@option{-T
  4871. @var{file-of-names}}) option to @command{tar}. Give the name of the
  4872. file which contains the list of files to include as the argument to
  4873. @option{--files-from}. In the list, the file names should be separated by
  4874. newlines. You will frequently use this option when you have generated
  4875. the list of files to archive with the @command{find} utility.
  4876. @table @option
  4877. @opindex files-from
  4878. @item --files-from=@var{file-name}
  4879. @itemx -T @var{file-name}
  4880. Get names to extract or create from file @var{file-name}.
  4881. @end table
  4882. If you give a single dash as a file name for @option{--files-from}, (i.e.,
  4883. you specify either @code{--files-from=-} or @code{-T -}), then the file
  4884. names are read from standard input.
  4885. Unless you are running @command{tar} with @option{--create}, you can not use
  4886. both @code{--files-from=-} and @code{--file=-} (@code{-f -}) in the same
  4887. command.
  4888. Any number of @option{-T} options can be given in the command line.
  4889. The following example shows how to use @command{find} to generate a list of
  4890. files smaller than 400K in length and put that list into a file
  4891. called @file{small-files}. You can then use the @option{-T} option to
  4892. @command{tar} to specify the files from that file, @file{small-files}, to
  4893. create the archive @file{little.tgz}. (The @option{-z} option to
  4894. @command{tar} compresses the archive with @command{gzip}; @pxref{gzip} for
  4895. more information.)
  4896. @smallexample
  4897. $ @kbd{find . -size -400 -print > small-files}
  4898. $ @kbd{tar -c -v -z -T small-files -f little.tgz}
  4899. @end smallexample
  4900. @noindent
  4901. In the file list given by @option{-T} option, any file name beginning
  4902. with @samp{-} character is considered a @command{tar} option and is
  4903. processed accordingly.@footnote{Versions of @GNUTAR{} up to 1.15.1
  4904. recognized only @option{-C} option in file lists, and only if the
  4905. option and its argument occupied two consecutive lines.} For example,
  4906. the common use of this feature is to change to another directory by
  4907. specifying @option{-C} option:
  4908. @smallexample
  4909. @group
  4910. $ @kbd{cat list}
  4911. -C/etc
  4912. passwd
  4913. hosts
  4914. -C/lib
  4915. libc.a
  4916. $ @kbd{tar -c -f foo.tar --files-from list}
  4917. @end group
  4918. @end smallexample
  4919. @noindent
  4920. In this example, @command{tar} will first switch to @file{/etc}
  4921. directory and add files @file{passwd} and @file{hosts} to the
  4922. archive. Then it will change to @file{/lib} directory and will archive
  4923. the file @file{libc.a}. Thus, the resulting archive @file{foo.tar} will
  4924. contain:
  4925. @smallexample
  4926. @group
  4927. $ @kbd{tar tf foo.tar}
  4928. passwd
  4929. hosts
  4930. libc.a
  4931. @end group
  4932. @end smallexample
  4933. @noindent
  4934. @opindex directory, using in @option{--files-from} argument
  4935. Notice that the option parsing algorithm used with @option{-T} is
  4936. stricter than the one used by shell. Namely, when specifying option
  4937. arguments, you should observe the following rules:
  4938. @itemize @bullet
  4939. @item
  4940. When using short (single-letter) option form, its argument must
  4941. immediately follow the option letter, without any intervening
  4942. whitespace. For example: @code{-Cdir}.
  4943. @item
  4944. When using long option form, the option argument must be separated
  4945. from the option by a single equal sign. No whitespace is allowed on
  4946. any side of the equal sign. For example: @code{--directory=dir}.
  4947. @item
  4948. For both short and long option forms, the option argument can be given
  4949. on the next line after the option name, e.g.:
  4950. @smallexample
  4951. @group
  4952. --directory
  4953. dir
  4954. @end group
  4955. @end smallexample
  4956. @noindent
  4957. and
  4958. @smallexample
  4959. @group
  4960. -C
  4961. dir
  4962. @end group
  4963. @end smallexample
  4964. @end itemize
  4965. @opindex add-file
  4966. If you happen to have a file whose name starts with @samp{-},
  4967. precede it with @option{--add-file} option to prevent it from
  4968. being recognized as an option. For example: @code{--add-file=--my-file}.
  4969. @menu
  4970. * nul::
  4971. @end menu
  4972. @node nul
  4973. @subsection @code{NUL} Terminated File Names
  4974. @cindex File names, terminated by @code{NUL}
  4975. @cindex @code{NUL} terminated file names
  4976. The @option{--null} option causes
  4977. @option{--files-from=@var{file-of-names}} (@option{-T @var{file-of-names}})
  4978. to read file names terminated by a @code{NUL} instead of a newline, so
  4979. files whose names contain newlines can be archived using
  4980. @option{--files-from}.
  4981. @table @option
  4982. @opindex null
  4983. @item --null
  4984. Only consider @code{NUL} terminated file names, instead of files that
  4985. terminate in a newline.
  4986. @end table
  4987. The @option{--null} option is just like the one in @acronym{GNU}
  4988. @command{xargs} and @command{cpio}, and is useful with the
  4989. @option{-print0} predicate of @acronym{GNU} @command{find}. In
  4990. @command{tar}, @option{--null} also disables special handling for
  4991. file names that begin with dash.
  4992. This example shows how to use @command{find} to generate a list of files
  4993. larger than 800K in length and put that list into a file called
  4994. @file{long-files}. The @option{-print0} option to @command{find} is just
  4995. like @option{-print}, except that it separates files with a @code{NUL}
  4996. rather than with a newline. You can then run @command{tar} with both the
  4997. @option{--null} and @option{-T} options to specify that @command{tar} get the
  4998. files from that file, @file{long-files}, to create the archive
  4999. @file{big.tgz}. The @option{--null} option to @command{tar} will cause
  5000. @command{tar} to recognize the @code{NUL} separator between files.
  5001. @smallexample
  5002. $ @kbd{find . -size +800 -print0 > long-files}
  5003. $ @kbd{tar -c -v --null --files-from=long-files --file=big.tar}
  5004. @end smallexample
  5005. @FIXME{say anything else here to conclude the section?}
  5006. @node exclude
  5007. @section Excluding Some Files
  5008. @UNREVISED
  5009. @cindex File names, excluding files by
  5010. @cindex Excluding files by name and pattern
  5011. @cindex Excluding files by file system
  5012. To avoid operating on files whose names match a particular pattern,
  5013. use the @option{--exclude} or @option{--exclude-from} options.
  5014. @table @option
  5015. @opindex exclude
  5016. @item --exclude=@var{pattern}
  5017. Causes @command{tar} to ignore files that match the @var{pattern}.
  5018. @end table
  5019. @findex exclude
  5020. The @option{--exclude=@var{pattern}} option prevents any file or
  5021. member whose name matches the shell wildcard (@var{pattern}) from
  5022. being operated on.
  5023. For example, to create an archive with all the contents of the directory
  5024. @file{src} except for files whose names end in @file{.o}, use the
  5025. command @samp{tar -cf src.tar --exclude='*.o' src}.
  5026. You may give multiple @option{--exclude} options.
  5027. @table @option
  5028. @opindex exclude-from
  5029. @item --exclude-from=@var{file}
  5030. @itemx -X @var{file}
  5031. Causes @command{tar} to ignore files that match the patterns listed in
  5032. @var{file}.
  5033. @end table
  5034. @findex exclude-from
  5035. Use the @option{--exclude-from} option to read a
  5036. list of patterns, one per line, from @var{file}; @command{tar} will
  5037. ignore files matching those patterns. Thus if @command{tar} is
  5038. called as @w{@samp{tar -c -X foo .}} and the file @file{foo} contains a
  5039. single line @file{*.o}, no files whose names end in @file{.o} will be
  5040. added to the archive.
  5041. @table @option
  5042. @opindex exclude-caches
  5043. @item --exclude-caches
  5044. Causes @command{tar} to ignore directories containing a cache directory tag.
  5045. @end table
  5046. @findex exclude-caches
  5047. When creating an archive, the @option{--exclude-caches} option causes
  5048. @command{tar} to exclude all directories that contain a @dfn{cache
  5049. directory tag}. A cache directory tag is a short file with the
  5050. well-known name @file{CACHEDIR.TAG} and having a standard header
  5051. specified in @url{http://www.brynosaurus.com/cachedir/spec.html}.
  5052. Various applications write cache directory tags into directories they
  5053. use to hold regenerable, non-precious data, so that such data can be
  5054. more easily excluded from backups.
  5055. @menu
  5056. * problems with exclude::
  5057. @end menu
  5058. @node problems with exclude
  5059. @unnumberedsubsec Problems with Using the @code{exclude} Options
  5060. @opindex exclude, potential problems with
  5061. Some users find @samp{exclude} options confusing. Here are some common
  5062. pitfalls:
  5063. @itemize @bullet
  5064. @item
  5065. The main operating mode of @command{tar} does not act on a path name
  5066. explicitly listed on the command line if one of its file name
  5067. components is excluded. In the example above, if
  5068. you create an archive and exclude files that end with @samp{*.o}, but
  5069. explicitly name the file @samp{dir.o/foo} after all the options have been
  5070. listed, @samp{dir.o/foo} will be excluded from the archive.
  5071. @item
  5072. You can sometimes confuse the meanings of @option{--exclude} and
  5073. @option{--exclude-from}. Be careful: use @option{--exclude} when files
  5074. to be excluded are given as a pattern on the command line. Use
  5075. @option{--exclude-from} to introduce the name of a file which contains
  5076. a list of patterns, one per line; each of these patterns can exclude
  5077. zero, one, or many files.
  5078. @item
  5079. When you use @option{--exclude=@var{pattern}}, be sure to quote the
  5080. @var{pattern} parameter, so @GNUTAR{} sees wildcard characters
  5081. like @samp{*}. If you do not do this, the shell might expand the
  5082. @samp{*} itself using files at hand, so @command{tar} might receive a
  5083. list of files instead of one pattern, or none at all, making the
  5084. command somewhat illegal. This might not correspond to what you want.
  5085. For example, write:
  5086. @smallexample
  5087. $ @kbd{tar -c -f @var{archive.tar} --exclude '*.o' @var{directory}}
  5088. @end smallexample
  5089. @noindent
  5090. rather than:
  5091. @smallexample
  5092. # @emph{Wrong!}
  5093. $ @kbd{tar -c -f @var{archive.tar} --exclude *.o @var{directory}}
  5094. @end smallexample
  5095. @item
  5096. You must use use shell syntax, or globbing, rather than @code{regexp}
  5097. syntax, when using exclude options in @command{tar}. If you try to use
  5098. @code{regexp} syntax to describe files to be excluded, your command
  5099. might fail.
  5100. @item
  5101. @FIXME{The change in semantics must have occurred before 1.11,
  5102. so I doubt if it is worth mentioning at all. Anyway, should at
  5103. least specify in which version the semantics changed.}
  5104. In earlier versions of @command{tar}, what is now the
  5105. @option{--exclude-from} option was called @option{--exclude} instead.
  5106. Now, @option{--exclude} applies to patterns listed on the command
  5107. line and @option{--exclude-from} applies to patterns listed in a
  5108. file.
  5109. @end itemize
  5110. @node wildcards
  5111. @section Wildcards Patterns and Matching
  5112. @dfn{Globbing} is the operation by which @dfn{wildcard} characters,
  5113. @samp{*} or @samp{?} for example, are replaced and expanded into all
  5114. existing files matching the given pattern. @GNUTAR{} can use wildcard
  5115. patterns for matching (or globbing) archive members when extracting
  5116. from or listing an archive. Wildcard patterns are also used for
  5117. verifying volume labels of @command{tar} archives. This section has the
  5118. purpose of explaining wildcard syntax for @command{tar}.
  5119. @FIXME{the next few paragraphs need work.}
  5120. A @var{pattern} should be written according to shell syntax, using wildcard
  5121. characters to effect globbing. Most characters in the pattern stand
  5122. for themselves in the matched string, and case is significant: @samp{a}
  5123. will match only @samp{a}, and not @samp{A}. The character @samp{?} in the
  5124. pattern matches any single character in the matched string. The character
  5125. @samp{*} in the pattern matches zero, one, or more single characters in
  5126. the matched string. The character @samp{\} says to take the following
  5127. character of the pattern @emph{literally}; it is useful when one needs to
  5128. match the @samp{?}, @samp{*}, @samp{[} or @samp{\} characters, themselves.
  5129. The character @samp{[}, up to the matching @samp{]}, introduces a character
  5130. class. A @dfn{character class} is a list of acceptable characters
  5131. for the next single character of the matched string. For example,
  5132. @samp{[abcde]} would match any of the first five letters of the alphabet.
  5133. Note that within a character class, all of the ``special characters''
  5134. listed above other than @samp{\} lose their special meaning; for example,
  5135. @samp{[-\\[*?]]} would match any of the characters, @samp{-}, @samp{\},
  5136. @samp{[}, @samp{*}, @samp{?}, or @samp{]}. (Due to parsing constraints,
  5137. the characters @samp{-} and @samp{]} must either come @emph{first} or
  5138. @emph{last} in a character class.)
  5139. @cindex Excluding characters from a character class
  5140. @cindex Character class, excluding characters from
  5141. If the first character of the class after the opening @samp{[}
  5142. is @samp{!} or @samp{^}, then the meaning of the class is reversed.
  5143. Rather than listing character to match, it lists those characters which
  5144. are @emph{forbidden} as the next single character of the matched string.
  5145. Other characters of the class stand for themselves. The special
  5146. construction @samp{[@var{a}-@var{e}]}, using an hyphen between two
  5147. letters, is meant to represent all characters between @var{a} and
  5148. @var{e}, inclusive.
  5149. @FIXME{need to add a sentence or so here to make this clear for those
  5150. who don't have dan around.}
  5151. Periods (@samp{.}) or forward slashes (@samp{/}) are not considered
  5152. special for wildcard matches. However, if a pattern completely matches
  5153. a directory prefix of a matched string, then it matches the full matched
  5154. string: thus, excluding a directory also excludes all the files beneath it.
  5155. @menu
  5156. * controlling pattern-matching::
  5157. @end menu
  5158. @node controlling pattern-matching
  5159. @unnumberedsubsec Controlling Pattern-Matching
  5160. For the purposes of this section, we call @dfn{exclusion members} all
  5161. member names obtained while processing @option{--exclude} and
  5162. @option{--exclude-from} options, and @dfn{inclusion members} those
  5163. member names that were given in the command line or read from the file
  5164. specified with @option{--files-from} option.
  5165. These two pairs of member lists are used in the following operations:
  5166. @option{--diff}, @option{--extract}, @option{--list},
  5167. @option{--update}.
  5168. There are no inclusion members in create mode (@option{--create} and
  5169. @option{--append}), since in this mode the names obtained from the
  5170. command line refer to @emph{files}, not archive members.
  5171. By default, inclusion members are compared with archive members
  5172. literally @footnote{Notice that earlier @GNUTAR{} versions used
  5173. globbing for inclusion members, which contradicted to UNIX98
  5174. specification and was not documented. @xref{Changes}, for more
  5175. information on this and other changes} and exclusion members are
  5176. treated as globbing patterns. For example:
  5177. @smallexample
  5178. @group
  5179. $ @kbd{tar tf foo.tar}
  5180. a.c
  5181. b.c
  5182. a.txt
  5183. [remarks]
  5184. # @i{Member names are used verbatim:}
  5185. $ @kbd{tar -xf foo.tar -v '[remarks]'}
  5186. [remarks]
  5187. # @i{Exclude member names are globbed:}
  5188. $ @kbd{tar -xf foo.tar -v --exclude '*.c'}
  5189. a.txt
  5190. [remarks]
  5191. @end group
  5192. @end smallexample
  5193. This behavior can be altered by using the following options:
  5194. @table @option
  5195. @opindex wildcards
  5196. @item --wildcards
  5197. Treat all member names as wildcards.
  5198. @opindex no-wildcards
  5199. @item --no-wildcards
  5200. Treat all member names as literal strings.
  5201. @end table
  5202. Thus, to extract files whose names end in @samp{.c}, you can use:
  5203. @smallexample
  5204. $ @kbd{tar -xf foo.tar -v --wildcards '*.c'}
  5205. a.c
  5206. b.c
  5207. @end smallexample
  5208. @noindent
  5209. Notice quoting of the pattern to prevent the shell from interpreting
  5210. it.
  5211. The effect of @option{--wildcards} option is cancelled by
  5212. @option{--no-wildcards}. This can be used to pass part of
  5213. the command line arguments verbatim and other part as globbing
  5214. patterns. For example, the following invocation:
  5215. @smallexample
  5216. $ @kbd{tar -xf foo.tar --wildcards '*.txt' --no-wildcards '[remarks]'}
  5217. @end smallexample
  5218. @noindent
  5219. instructs @command{tar} to extract from @file{foo.tar} all files whose
  5220. names end in @samp{.txt} and the file named @file{[remarks]}.
  5221. Normally, a pattern matches a name if an initial subsequence of the
  5222. name's components matches the pattern, where @samp{*}, @samp{?}, and
  5223. @samp{[...]} are the usual shell wildcards, @samp{\} escapes wildcards,
  5224. and wildcards can match @samp{/}.
  5225. Other than optionally stripping leading @samp{/} from names
  5226. (@pxref{absolute}), patterns and names are used as-is. For
  5227. example, trailing @samp{/} is not trimmed from a user-specified name
  5228. before deciding whether to exclude it.
  5229. However, this matching procedure can be altered by the options listed
  5230. below. These options accumulate. For example:
  5231. @smallexample
  5232. --ignore-case --exclude='makefile' --no-ignore-case ---exclude='readme'
  5233. @end smallexample
  5234. ignores case when excluding @samp{makefile}, but not when excluding
  5235. @samp{readme}.
  5236. @table @option
  5237. @opindex anchored
  5238. @opindex no-anchored
  5239. @item --anchored
  5240. @itemx --no-anchored
  5241. If anchored, a pattern must match an initial subsequence
  5242. of the name's components. Otherwise, the pattern can match any
  5243. subsequence. Default is @option{--no-anchored} for exclusion members
  5244. and @option{--anchored} inclusion members.
  5245. @opindex ignore-case
  5246. @opindex no-ignore-case
  5247. @item --ignore-case
  5248. @itemx --no-ignore-case
  5249. When ignoring case, upper-case patterns match lower-case names and vice versa.
  5250. When not ignoring case (the default), matching is case-sensitive.
  5251. @opindex wildcards-match-slash
  5252. @opindex no-wildcards-match-slash
  5253. @item --wildcards-match-slash
  5254. @itemx --no-wildcards-match-slash
  5255. When wildcards match slash (the default for exclusion members), a
  5256. wildcard like @samp{*} in the pattern can match a @samp{/} in the
  5257. name. Otherwise, @samp{/} is matched only by @samp{/}.
  5258. @end table
  5259. The @option{--recursion} and @option{--no-recursion} options
  5260. (@pxref{recurse}) also affect how member patterns are interpreted. If
  5261. recursion is in effect, a pattern matches a name if it matches any of
  5262. the name's parent directories.
  5263. The following table summarizes pattern-matching default values:
  5264. @multitable @columnfractions .3 .7
  5265. @headitem Members @tab Default settings
  5266. @item Inclusion @tab @option{--no-wildcards --anchored --no-wildcards-match-slash}
  5267. @item Exclusion @tab @option{--wildcards --no-anchored --wildcards-match-slash}
  5268. @end multitable
  5269. @node quoting styles
  5270. @section Quoting Member Names
  5271. When displaying member names, @command{tar} takes care to avoid
  5272. ambiguities caused by certain characters. This is called @dfn{name
  5273. quoting}. The characters in question are:
  5274. @itemize @bullet
  5275. @item Non-printable control characters:
  5276. @multitable @columnfractions 0.20 0.10 0.60
  5277. @headitem Character @tab ASCII @tab Character name
  5278. @item \a @tab 7 @tab Audible bell
  5279. @item \b @tab 8 @tab Backspace
  5280. @item \f @tab 12 @tab Form feed
  5281. @item \n @tab 10 @tab New line
  5282. @item \r @tab 13 @tab Carriage return
  5283. @item \t @tab 9 @tab Horizontal tabulation
  5284. @item \v @tab 11 @tab Vertical tabulation
  5285. @end multitable
  5286. @item Space (ASCII 32)
  5287. @item Single and double quotes (@samp{'} and @samp{"})
  5288. @item Backslash (@samp{\})
  5289. @end itemize
  5290. The exact way @command{tar} uses to quote these characters depends on
  5291. the @dfn{quoting style}. The default quoting style, called
  5292. @dfn{escape} (see below), uses backslash notation to represent control
  5293. characters, space and backslash. Using this quoting style, control
  5294. characters are represented as listed in column @samp{Character} in the
  5295. above table, a space is printed as @samp{\ } and a backslash as @samp{\\}.
  5296. @GNUTAR{} offers seven distinct quoting styles, which can be selected
  5297. using @option{--quoting-style} option:
  5298. @table @option
  5299. @item --quoting-style=@var{style}
  5300. @opindex quoting-style
  5301. Sets quoting style. Valid values for @var{style} argument are:
  5302. literal, shell, shell-always, c, escape, locale, clocale.
  5303. @end table
  5304. These styles are described in detail below. To illustrate their
  5305. effect, we will use an imaginary tar archive @file{arch.tar}
  5306. containing the following members:
  5307. @smallexample
  5308. @group
  5309. # 1. Contains horizontal tabulation character.
  5310. a tab
  5311. # 2. Contains newline character
  5312. a
  5313. newline
  5314. # 3. Contains a space
  5315. a space
  5316. # 4. Contains double quotes
  5317. a"double"quote
  5318. # 5. Contains single quotes
  5319. a'single'quote
  5320. # 6. Contains a backslash character:
  5321. a\backslash
  5322. @end group
  5323. @end smallexample
  5324. Here is how usual @command{ls} command would have listed them, if they
  5325. had existed in the current working directory:
  5326. @smallexample
  5327. @group
  5328. $ @kbd{ls}
  5329. a\ttab
  5330. a\nnewline
  5331. a\ space
  5332. a"double"quote
  5333. a'single'quote
  5334. a\\backslash
  5335. @end group
  5336. @end smallexample
  5337. Quoting styles:
  5338. @table @samp
  5339. @item literal
  5340. No quoting, display each character as is:
  5341. @smallexample
  5342. @group
  5343. $ @kbd{tar tf arch.tar --quoting-style=literal}
  5344. ./
  5345. ./a space
  5346. ./a'single'quote
  5347. ./a"double"quote
  5348. ./a\backslash
  5349. ./a tab
  5350. ./a
  5351. newline
  5352. @end group
  5353. @end smallexample
  5354. @item shell
  5355. Display characters the same way Bourne shell does:
  5356. control characters, except @samp{\t} and @samp{\n}, are printed using
  5357. backslash escapes, @samp{\t} and @samp{\n} are printed as is, and a
  5358. single quote is printed as @samp{\'}. If a name contains any quoted
  5359. characters, it is enclosed in single quotes. In particular, if a name
  5360. contains single quotes, it is printed as several single-quoted strings:
  5361. @smallexample
  5362. @group
  5363. $ @kbd{tar tf arch.tar --quoting-style=shell}
  5364. ./
  5365. './a space'
  5366. './a'\''single'\''quote'
  5367. './a"double"quote'
  5368. './a\backslash'
  5369. './a tab'
  5370. './a
  5371. newline'
  5372. @end group
  5373. @end smallexample
  5374. @item shell-always
  5375. Same as @samp{shell}, but the names are always enclosed in single
  5376. quotes:
  5377. @smallexample
  5378. @group
  5379. $ @kbd{tar tf arch.tar --quoting-style=shell-always}
  5380. './'
  5381. './a space'
  5382. './a'\''single'\''quote'
  5383. './a"double"quote'
  5384. './a\backslash'
  5385. './a tab'
  5386. './a
  5387. newline'
  5388. @end group
  5389. @end smallexample
  5390. @item c
  5391. Use the notation of the C programming language. All names are
  5392. enclosed in double quotes. Control characters are quoted using
  5393. backslash notations, double quotes are represented as @samp{\"},
  5394. backslash characters are represented as @samp{\\}. Single quotes and
  5395. spaces are not quoted:
  5396. @smallexample
  5397. @group
  5398. $ @kbd{tar tf arch.tar --quoting-style=c}
  5399. "./"
  5400. "./a space"
  5401. "./a'single'quote"
  5402. "./a\"double\"quote"
  5403. "./a\\backslash"
  5404. "./a\ttab"
  5405. "./a\nnewline"
  5406. @end group
  5407. @end smallexample
  5408. @item escape
  5409. Control characters are printed using backslash notation, a space is
  5410. printed as @samp{\ } and a backslash as @samp{\\}. This is the
  5411. default quoting style, unless it was changed when configured the
  5412. package.
  5413. @smallexample
  5414. @group
  5415. $ @kbd{tar tf arch.tar --quoting-style=escape}
  5416. ./
  5417. ./a space
  5418. ./a'single'quote
  5419. ./a"double"quote
  5420. ./a\\backslash
  5421. ./a\ttab
  5422. ./a\nnewline
  5423. @end group
  5424. @end smallexample
  5425. @item locale
  5426. Control characters, single quote and backslash are printed using
  5427. backslash notation. All names are quoted using left and right
  5428. quotation marks, appropriate to the current locale. If it does not
  5429. define quotation marks, use @samp{`} as left and @samp{'} as right
  5430. quotation marks. Any occurrences of the right quotation mark in a
  5431. name are escaped with @samp{\}, for example:
  5432. For example:
  5433. @smallexample
  5434. @group
  5435. $ @kbd{tar tf arch.tar --quoting-style=locale}
  5436. `./'
  5437. `./a space'
  5438. `./a\'single\'quote'
  5439. `./a"double"quote'
  5440. `./a\\backslash'
  5441. `./a\ttab'
  5442. `./a\nnewline'
  5443. @end group
  5444. @end smallexample
  5445. @item clocale
  5446. Same as @samp{locale}, but @samp{"} is used for both left and right
  5447. quotation marks, if not provided by the currently selected locale:
  5448. @smallexample
  5449. @group
  5450. $ @kbd{tar tf arch.tar --quoting-style=clocale}
  5451. "./"
  5452. "./a space"
  5453. "./a'single'quote"
  5454. "./a\"double\"quote"
  5455. "./a\\backslash"
  5456. "./a\ttab"
  5457. "./a\nnewline"
  5458. @end group
  5459. @end smallexample
  5460. @end table
  5461. You can specify which characters should be quoted in addition to those
  5462. implied by the current quoting style:
  5463. @table @option
  5464. @item --quote-chars=@var{string}
  5465. Always quote characters from @var{string}, even if the selected
  5466. quoting style would not quote them.
  5467. @end table
  5468. For example, using @samp{escape} quoting (compare with the usual
  5469. escape listing above):
  5470. @smallexample
  5471. @group
  5472. $ @kbd{tar tf arch.tar --quoting-style=escape --quote-chars=' "'}
  5473. ./
  5474. ./a\ space
  5475. ./a'single'quote
  5476. ./a\"double\"quote
  5477. ./a\\backslash
  5478. ./a\ttab
  5479. ./a\nnewline
  5480. @end group
  5481. @end smallexample
  5482. To disable quoting of such additional characters, use the following
  5483. option:
  5484. @table @option
  5485. @item --no-quote-chars=@var{string}
  5486. Remove characters listed in @var{string} from the list of quoted
  5487. characters set by the previous @option{--quote-chars} option.
  5488. @end table
  5489. This option is particularly useful if you have added
  5490. @option{--quote-chars} to your @env{TAR_OPTIONS} (@pxref{TAR_OPTIONS})
  5491. and wish to disable it for the current invocation.
  5492. Note, that @option{--no-quote-chars} does @emph{not} disable those
  5493. characters that are quoted by default in the selected quoting style.
  5494. @node transform
  5495. @section Modifying File and Member Names
  5496. @command{Tar} archives contain detailed information about files stored
  5497. in them and full file names are part of that information. When
  5498. storing file to an archive, its file name is recorded in the archive
  5499. along with the actual file contents. When restoring from an archive,
  5500. a file is created on disk with exactly the same name as that stored
  5501. in the archive. In the majority of cases this is the desired behavior
  5502. of a file archiver. However, there are some cases when it is not.
  5503. First of all, it is often unsafe to extract archive members with
  5504. absolute file names or those that begin with a @file{../}. @GNUTAR{}
  5505. takes special precautions when extracting such names and provides a
  5506. special option for handling them, which is described in
  5507. @xref{absolute}.
  5508. Secondly, you may wish to extract file names without some leading
  5509. directory components, or with otherwise modified names. In other
  5510. cases it is desirable to store files under differing names in the
  5511. archive.
  5512. @GNUTAR{} provides two options for these needs.
  5513. @table @option
  5514. @opindex strip-components
  5515. @item --strip-components=@var{number}
  5516. Strip given @var{number} of leading components from file names before
  5517. extraction.
  5518. @end table
  5519. For example, suppose you have archived whole @file{/usr} hierarchy to
  5520. a tar archive named @file{usr.tar}. Among other files, this archive
  5521. contains @file{usr/include/stdlib.h}, which you wish to extract to
  5522. the current working directory. To do so, you type:
  5523. @smallexample
  5524. $ @kbd{tar -xf usr.tar --strip=2 usr/include/stdlib.h}
  5525. @end smallexample
  5526. The option @option{--strip=2} instructs @command{tar} to strip the
  5527. two leading components (@file{usr/} and @file{include/}) off the file
  5528. name.
  5529. If you add to the above invocation @option{--verbose} (@option{-v})
  5530. option, you will note that the verbose listing still contains the
  5531. full file name, with the two removed components still in place. This
  5532. can be inconvenient, so @command{tar} provides a special option for
  5533. altering this behavior:
  5534. @anchor{show-transformed-names}
  5535. @table @option
  5536. @opindex --show-transformed-names
  5537. @item --show-transformed-names
  5538. Display file or member names with all requested transformations
  5539. applied.
  5540. @end table
  5541. For example:
  5542. @smallexample
  5543. @group
  5544. $ @kbd{tar -xf usr.tar -v --strip=2 usr/include/stdlib.h}
  5545. usr/include/stdlib.h
  5546. $ @kbd{tar -xf usr.tar -v --strip=2 --show-transformed usr/include/stdlib.h}
  5547. stdlib.h
  5548. @end group
  5549. @end smallexample
  5550. Notice that in both cases the file is @file{stdlib.h} extracted to the
  5551. current working directory, @option{--show-transformed-names} affects
  5552. only the way its name is displayed.
  5553. This option is especially useful for verifying whether the invocation
  5554. will have the desired effect. Thus, before running
  5555. @smallexample
  5556. $ @kbd{tar -x --strip=@var{n}}
  5557. @end smallexample
  5558. @noindent
  5559. it is often advisable to run
  5560. @smallexample
  5561. $ @kbd{tar -t -v --show-transformed --strip=@var{n}}
  5562. @end smallexample
  5563. @noindent
  5564. to make sure the command will produce the intended results.
  5565. In case you need to apply more complex modifications to the file name,
  5566. @GNUTAR{} provides a general-purpose transformation option:
  5567. @table @option
  5568. @opindex --transform
  5569. @item --transform=@var{expression}
  5570. Modify file names using supplied @var{expression}.
  5571. @end table
  5572. @noindent
  5573. The @var{expression} is a @command{sed}-like replace expression of the
  5574. form:
  5575. @smallexample
  5576. s/@var{regexp}/@var{replace}/[@var{flags}]
  5577. @end smallexample
  5578. @noindent
  5579. where @var{regexp} is a @dfn{regular expression}, @var{replace} is a
  5580. replacement for each file name part that matches @var{regexp}. Both
  5581. @var{regexp} and @var{replace} are described in detail in
  5582. @ref{The "s" Command, The "s" Command, The `s' Command, sed, GNU sed}.
  5583. Supported @var{flags} are:
  5584. @table @samp
  5585. @item g
  5586. Apply the replacement to @emph{all} matches to the @var{regexp}, not
  5587. just the first.
  5588. @item i
  5589. Use case-insensitive matching
  5590. @item x
  5591. @var{regexp} is an @dfn{extended regular expression} (@pxref{Extended
  5592. regexps, Extended regular expressions, Extended regular expressions,
  5593. sed, GNU sed}.
  5594. @item @var{number}
  5595. Only replace the @var{number}th match of the @var{regexp}.
  5596. Note: the @var{posix} standard does not specify what should happen
  5597. when you mix the @samp{g} and @var{number} modifiers. @GNUTAR{}
  5598. follows the GNU @command{sed} implementation in this regard, so
  5599. the the interaction is defined to be: ignore matches before the
  5600. @var{number}th, and then match and replace all matches from the
  5601. @var{number}th on.
  5602. @end table
  5603. Any delimiter can be used in lieue of @samp{/}, the only requirement being
  5604. that it be used consistently throughout the expression. For example,
  5605. the following two expressions are equivalent:
  5606. @smallexample
  5607. @group
  5608. s/one/two/
  5609. s,one,two,
  5610. @end group
  5611. @end smallexample
  5612. Changing of delimiter is often useful when the @var{regex} contains
  5613. slashes. For example, it is more convenient to write:
  5614. @smallexample
  5615. s,/,-,
  5616. @end smallexample
  5617. @noindent
  5618. instead of
  5619. @smallexample
  5620. s/\//-/
  5621. @end smallexample
  5622. Here are several examples of @option{--transform} usage:
  5623. @enumerate
  5624. @item Extract @file{usr/} hierarchy into @file{usr/local/}:
  5625. @smallexample
  5626. $ @kbd{tar --transform='s,usr/,usr/local/,' -x -f arch.tar}
  5627. @end smallexample
  5628. @item Strip two leading directory components (equivalent to
  5629. @option{--strip-components=2}):
  5630. @smallexample
  5631. $ @kbd{tar --transform='s,/*[^/]*/[^/]*/,,' -x -f arch.tar}
  5632. @end smallexample
  5633. @item Prepend @file{/prefix/} to each file name:
  5634. @smallexample
  5635. $ @kbd{tar --transform 's,^,/prefix/,' -x -f arch.tar}
  5636. @end smallexample
  5637. @item Convert each file name to lower case:
  5638. @smallexample
  5639. $ @kbd{tar --transform 's/.*/\L&/' -x -f arch.tar}
  5640. @end smallexample
  5641. @end enumerate
  5642. Unlike @option{--strip-components}, @option{--transform} can be used
  5643. in any @GNUTAR{} operation mode. For example, the following command
  5644. adds files to the archive while replacing the leading @file{usr/}
  5645. component with @file{var/}:
  5646. @smallexample
  5647. $ @kbd{tar -cf arch.tar --transform='s,^usr/,var/,' /}
  5648. @end smallexample
  5649. To test @option{--transform} effect we suggest to use
  5650. @option{--show-transformed-names}:
  5651. @smallexample
  5652. $ @kbd{tar -cf arch.tar --transform='s,^usr/,var/,' \
  5653. --verbose --show-transformed-names /}
  5654. @end smallexample
  5655. If both @option{--strip-components} and @option{--transform} are used
  5656. together, then @option{--transform} is applied first, and the required
  5657. number of components is then stripped from its result.
  5658. @node after
  5659. @section Operating Only on New Files
  5660. @UNREVISED
  5661. @cindex Excluding file by age
  5662. @cindex Data Modification time, excluding files by
  5663. @cindex Modification time, excluding files by
  5664. @cindex Age, excluding files by
  5665. The @option{--after-date=@var{date}} (@option{--newer=@var{date}},
  5666. @option{-N @var{date}}) option causes @command{tar} to only work on
  5667. files whose data modification or status change times are newer than
  5668. the @var{date} given. If @var{date} starts with @samp{/} or @samp{.},
  5669. it is taken to be a file name; the data modification time of that file
  5670. is used as the date. If you use this option when creating or appending
  5671. to an archive, the archive will only include new files. If you use
  5672. @option{--after-date} when extracting an archive, @command{tar} will
  5673. only extract files newer than the @var{date} you specify.
  5674. If you only want @command{tar} to make the date comparison based on
  5675. modification of the file's data (rather than status
  5676. changes), then use the @option{--newer-mtime=@var{date}} option.
  5677. You may use these options with any operation. Note that these options
  5678. differ from the @option{--update} (@option{-u}) operation in that they
  5679. allow you to specify a particular date against which @command{tar} can
  5680. compare when deciding whether or not to archive the files.
  5681. @table @option
  5682. @opindex after-date
  5683. @opindex newer
  5684. @item --after-date=@var{date}
  5685. @itemx --newer=@var{date}
  5686. @itemx -N @var{date}
  5687. Only store files newer than @var{date}.
  5688. Acts on files only if their data modification or status change times are
  5689. later than @var{date}. Use in conjunction with any operation.
  5690. If @var{date} starts with @samp{/} or @samp{.}, it is taken to be a file
  5691. name; the data modification time of that file is used as the date.
  5692. @opindex newer-mtime
  5693. @item --newer-mtime=@var{date}
  5694. Acts like @option{--after-date}, but only looks at data modification times.
  5695. @end table
  5696. These options limit @command{tar} to operate only on files which have
  5697. been modified after the date specified. A file's status is considered to have
  5698. changed if its contents have been modified, or if its owner,
  5699. permissions, and so forth, have been changed. (For more information on
  5700. how to specify a date, see @ref{Date input formats}; remember that the
  5701. entire date argument must be quoted if it contains any spaces.)
  5702. Gurus would say that @option{--after-date} tests both the data
  5703. modification time (@code{mtime}, the time the contents of the file
  5704. were last modified) and the status change time (@code{ctime}, the time
  5705. the file's status was last changed: owner, permissions, etc.@:)
  5706. fields, while @option{--newer-mtime} tests only the @code{mtime}
  5707. field.
  5708. To be precise, @option{--after-date} checks @emph{both} @code{mtime} and
  5709. @code{ctime} and processes the file if either one is more recent than
  5710. @var{date}, while @option{--newer-mtime} only checks @code{mtime} and
  5711. disregards @code{ctime}. Neither does it use @code{atime} (the last time the
  5712. contents of the file were looked at).
  5713. Date specifiers can have embedded spaces. Because of this, you may need
  5714. to quote date arguments to keep the shell from parsing them as separate
  5715. arguments. For example, the following command will add to the archive
  5716. all the files modified less than two days ago:
  5717. @smallexample
  5718. $ @kbd{tar -cf foo.tar --newer-mtime '2 days ago'}
  5719. @end smallexample
  5720. @quotation
  5721. @strong{Please Note:} @option{--after-date} and @option{--newer-mtime}
  5722. should not be used for incremental backups. @xref{Incremental Dumps},
  5723. for proper way of creating incremental backups.
  5724. @end quotation
  5725. @node recurse
  5726. @section Descending into Directories
  5727. @UNREVISED
  5728. @cindex Avoiding recursion in directories
  5729. @cindex Descending directories, avoiding
  5730. @cindex Directories, avoiding recursion
  5731. @cindex Recursion in directories, avoiding
  5732. @FIXME{arrggh! this is still somewhat confusing to me. :-< }
  5733. Usually, @command{tar} will recursively explore all directories (either
  5734. those given on the command line or through the @option{--files-from}
  5735. option) for the various files they contain. However, you may not always
  5736. want @command{tar} to act this way.
  5737. @opindex no-recursion
  5738. The @option{--no-recursion} option inhibits @command{tar}'s recursive descent
  5739. into specified directories. If you specify @option{--no-recursion}, you can
  5740. use the @command{find} utility for hunting through levels of directories to
  5741. construct a list of file names which you could then pass to @command{tar}.
  5742. @command{find} allows you to be more selective when choosing which files to
  5743. archive; see @ref{files}, for more information on using @command{find} with
  5744. @command{tar}, or look.
  5745. @table @option
  5746. @item --no-recursion
  5747. Prevents @command{tar} from recursively descending directories.
  5748. @opindex recursion
  5749. @item --recursion
  5750. Requires @command{tar} to recursively descend directories.
  5751. This is the default.
  5752. @end table
  5753. When you use @option{--no-recursion}, @GNUTAR{} grabs
  5754. directory entries themselves, but does not descend on them
  5755. recursively. Many people use @command{find} for locating files they
  5756. want to back up, and since @command{tar} @emph{usually} recursively
  5757. descends on directories, they have to use the @samp{@w{-not -type d}}
  5758. test in their @command{find} invocation (@pxref{Type, Type, Type test,
  5759. find, Finding Files}), as they usually do not want all the files in a
  5760. directory. They then use the @option{--files-from} option to archive
  5761. the files located via @command{find}.
  5762. The problem when restoring files archived in this manner is that the
  5763. directories themselves are not in the archive; so the
  5764. @option{--same-permissions} (@option{--preserve-permissions},
  5765. @option{-p}) option does not affect them---while users might really
  5766. like it to. Specifying @option{--no-recursion} is a way to tell
  5767. @command{tar} to grab only the directory entries given to it, adding
  5768. no new files on its own. To summarize, if you use @command{find} to
  5769. create a list of files to be stored in an archive, use it as follows:
  5770. @smallexample
  5771. @group
  5772. $ @kbd{find @var{dir} @var{tests} | \
  5773. tar -cf @var{archive} -T - --no-recursion}
  5774. @end group
  5775. @end smallexample
  5776. The @option{--no-recursion} option also applies when extracting: it
  5777. causes @command{tar} to extract only the matched directory entries, not
  5778. the files under those directories.
  5779. The @option{--no-recursion} option also affects how globbing patterns
  5780. are interpreted (@pxref{controlling pattern-matching}).
  5781. The @option{--no-recursion} and @option{--recursion} options apply to
  5782. later options and operands, and can be overridden by later occurrences
  5783. of @option{--no-recursion} and @option{--recursion}. For example:
  5784. @smallexample
  5785. $ @kbd{tar -cf jams.tar --no-recursion grape --recursion grape/concord}
  5786. @end smallexample
  5787. @noindent
  5788. creates an archive with one entry for @file{grape}, and the recursive
  5789. contents of @file{grape/concord}, but no entries under @file{grape}
  5790. other than @file{grape/concord}.
  5791. @node one
  5792. @section Crossing File System Boundaries
  5793. @cindex File system boundaries, not crossing
  5794. @UNREVISED
  5795. @command{tar} will normally automatically cross file system boundaries in
  5796. order to archive files which are part of a directory tree. You can
  5797. change this behavior by running @command{tar} and specifying
  5798. @option{--one-file-system}. This option only affects files that are
  5799. archived because they are in a directory that is being archived;
  5800. @command{tar} will still archive files explicitly named on the command line
  5801. or through @option{--files-from}, regardless of where they reside.
  5802. @table @option
  5803. @opindex one-file-system
  5804. @item --one-file-system
  5805. Prevents @command{tar} from crossing file system boundaries when
  5806. archiving. Use in conjunction with any write operation.
  5807. @end table
  5808. The @option{--one-file-system} option causes @command{tar} to modify its
  5809. normal behavior in archiving the contents of directories. If a file in
  5810. a directory is not on the same file system as the directory itself, then
  5811. @command{tar} will not archive that file. If the file is a directory
  5812. itself, @command{tar} will not archive anything beneath it; in other words,
  5813. @command{tar} will not cross mount points.
  5814. This option is useful for making full or incremental archival backups of
  5815. a file system. If this option is used in conjunction with
  5816. @option{--verbose} (@option{-v}), files that are excluded are
  5817. mentioned by name on the standard error.
  5818. @menu
  5819. * directory:: Changing Directory
  5820. * absolute:: Absolute File Names
  5821. @end menu
  5822. @node directory
  5823. @subsection Changing the Working Directory
  5824. @UNREVISED
  5825. @FIXME{need to read over this node now for continuity; i've switched
  5826. things around some.}
  5827. @cindex Changing directory mid-stream
  5828. @cindex Directory, changing mid-stream
  5829. @cindex Working directory, specifying
  5830. To change the working directory in the middle of a list of file names,
  5831. either on the command line or in a file specified using
  5832. @option{--files-from} (@option{-T}), use @option{--directory} (@option{-C}).
  5833. This will change the working directory to the specified directory
  5834. after that point in the list.
  5835. @table @option
  5836. @opindex directory
  5837. @item --directory=@var{directory}
  5838. @itemx -C @var{directory}
  5839. Changes the working directory in the middle of a command line.
  5840. @end table
  5841. For example,
  5842. @smallexample
  5843. $ @kbd{tar -c -f jams.tar grape prune -C food cherry}
  5844. @end smallexample
  5845. @noindent
  5846. will place the files @file{grape} and @file{prune} from the current
  5847. directory into the archive @file{jams.tar}, followed by the file
  5848. @file{cherry} from the directory @file{food}. This option is especially
  5849. useful when you have several widely separated files that you want to
  5850. store in the same archive.
  5851. Note that the file @file{cherry} is recorded in the archive under the
  5852. precise name @file{cherry}, @emph{not} @file{food/cherry}. Thus, the
  5853. archive will contain three files that all appear to have come from the
  5854. same directory; if the archive is extracted with plain @samp{tar
  5855. --extract}, all three files will be written in the current directory.
  5856. Contrast this with the command,
  5857. @smallexample
  5858. $ @kbd{tar -c -f jams.tar grape prune -C food red/cherry}
  5859. @end smallexample
  5860. @noindent
  5861. which records the third file in the archive under the name
  5862. @file{red/cherry} so that, if the archive is extracted using
  5863. @samp{tar --extract}, the third file will be written in a subdirectory
  5864. named @file{orange-colored}.
  5865. You can use the @option{--directory} option to make the archive
  5866. independent of the original name of the directory holding the files.
  5867. The following command places the files @file{/etc/passwd},
  5868. @file{/etc/hosts}, and @file{/lib/libc.a} into the archive
  5869. @file{foo.tar}:
  5870. @smallexample
  5871. $ @kbd{tar -c -f foo.tar -C /etc passwd hosts -C /lib libc.a}
  5872. @end smallexample
  5873. @noindent
  5874. However, the names of the archive members will be exactly what they were
  5875. on the command line: @file{passwd}, @file{hosts}, and @file{libc.a}.
  5876. They will not appear to be related by file name to the original
  5877. directories where those files were located.
  5878. Note that @option{--directory} options are interpreted consecutively. If
  5879. @option{--directory} specifies a relative file name, it is interpreted
  5880. relative to the then current directory, which might not be the same as
  5881. the original current working directory of @command{tar}, due to a previous
  5882. @option{--directory} option.
  5883. When using @option{--files-from} (@pxref{files}), you can put various
  5884. @command{tar} options (including @option{-C}) in the file list. Notice,
  5885. however, that in this case the option and its argument may not be
  5886. separated by whitespace. If you use short option, its argument must
  5887. either follow the option letter immediately, without any intervening
  5888. whitespace, or occupy the next line. Otherwise, if you use long
  5889. option, separate its argument by an equal sign.
  5890. For instance, the file list for the above example will be:
  5891. @smallexample
  5892. @group
  5893. -C
  5894. /etc
  5895. passwd
  5896. hosts
  5897. -C
  5898. /lib
  5899. libc.a
  5900. @end group
  5901. @end smallexample
  5902. @noindent
  5903. To use it, you would invoke @command{tar} as follows:
  5904. @smallexample
  5905. $ @kbd{tar -c -f foo.tar --files-from list}
  5906. @end smallexample
  5907. Notice also that you can only use the short option variant in the file
  5908. list, i.e., always use @option{-C}, not @option{--directory}.
  5909. The interpretation of @option{--directory} is disabled by
  5910. @option{--null} option.
  5911. @node absolute
  5912. @subsection Absolute File Names
  5913. @UNREVISED
  5914. @table @option
  5915. @opindex absolute-names
  5916. @item --absolute-names
  5917. @itemx -P
  5918. Do not strip leading slashes from file names, and permit file names
  5919. containing a @file{..} file name component.
  5920. @end table
  5921. By default, @GNUTAR{} drops a leading @samp{/} on
  5922. input or output, and complains about file names containing a @file{..}
  5923. component. This option turns off this behavior.
  5924. When @command{tar} extracts archive members from an archive, it strips any
  5925. leading slashes (@samp{/}) from the member name. This causes absolute
  5926. member names in the archive to be treated as relative file names. This
  5927. allows you to have such members extracted wherever you want, instead of
  5928. being restricted to extracting the member in the exact directory named
  5929. in the archive. For example, if the archive member has the name
  5930. @file{/etc/passwd}, @command{tar} will extract it as if the name were
  5931. really @file{etc/passwd}.
  5932. File names containing @file{..} can cause problems when extracting, so
  5933. @command{tar} normally warns you about such files when creating an
  5934. archive, and rejects attempts to extracts such files.
  5935. Other @command{tar} programs do not do this. As a result, if you
  5936. create an archive whose member names start with a slash, they will be
  5937. difficult for other people with a non-@GNUTAR{}
  5938. program to use. Therefore, @GNUTAR{} also strips
  5939. leading slashes from member names when putting members into the
  5940. archive. For example, if you ask @command{tar} to add the file
  5941. @file{/bin/ls} to an archive, it will do so, but the member name will
  5942. be @file{bin/ls}.@footnote{A side effect of this is that when
  5943. @option{--create} is used with @option{--verbose} the resulting output
  5944. is not, generally speaking, the same as the one you'd get running
  5945. @kbd{tar --list} command. This may be important if you use some
  5946. scripts for comparing both outputs. @xref{listing member and file names},
  5947. for the information on how to handle this case.}
  5948. If you use the @option{--absolute-names} (@option{-P}) option,
  5949. @command{tar} will do none of these transformations.
  5950. To archive or extract files relative to the root directory, specify
  5951. the @option{--absolute-names} (@option{-P}) option.
  5952. Normally, @command{tar} acts on files relative to the working
  5953. directory---ignoring superior directory names when archiving, and
  5954. ignoring leading slashes when extracting.
  5955. When you specify @option{--absolute-names} (@option{-P}),
  5956. @command{tar} stores file names including all superior directory
  5957. names, and preserves leading slashes. If you only invoked
  5958. @command{tar} from the root directory you would never need the
  5959. @option{--absolute-names} option, but using this option
  5960. may be more convenient than switching to root.
  5961. @FIXME{Should be an example in the tutorial/wizardry section using this
  5962. to transfer files between systems.}
  5963. @FIXME{Is write access an issue?}
  5964. @table @option
  5965. @item --absolute-names
  5966. Preserves full file names (including superior directory names) when
  5967. archiving files. Preserves leading slash when extracting files.
  5968. @end table
  5969. @FIXME{this is still horrible; need to talk with dan on monday.}
  5970. @command{tar} prints out a message about removing the @samp{/} from
  5971. file names. This message appears once per @GNUTAR{}
  5972. invocation. It represents something which ought to be told; ignoring
  5973. what it means can cause very serious surprises, later.
  5974. Some people, nevertheless, do not want to see this message. Wanting to
  5975. play really dangerously, one may of course redirect @command{tar} standard
  5976. error to the sink. For example, under @command{sh}:
  5977. @smallexample
  5978. $ @kbd{tar -c -f archive.tar /home 2> /dev/null}
  5979. @end smallexample
  5980. @noindent
  5981. Another solution, both nicer and simpler, would be to change to
  5982. the @file{/} directory first, and then avoid absolute notation.
  5983. For example:
  5984. @smallexample
  5985. $ @kbd{(cd / && tar -c -f archive.tar home)}
  5986. # @i{or}:
  5987. $ @kbd{tar -c -f archive.tar -C / home}
  5988. @end smallexample
  5989. @include getdate.texi
  5990. @node Formats
  5991. @chapter Controlling the Archive Format
  5992. @cindex Tar archive formats
  5993. Due to historical reasons, there are several formats of tar archives.
  5994. All of them are based on the same principles, but have some subtle
  5995. differences that often make them incompatible with each other.
  5996. GNU tar is able to create and handle archives in a variety of formats.
  5997. The most frequently used formats are (in alphabetical order):
  5998. @table @asis
  5999. @item gnu
  6000. Format used by @GNUTAR{} versions up to 1.13.25. This format derived
  6001. from an early @acronym{POSIX} standard, adding some improvements such as
  6002. sparse file handling and incremental archives. Unfortunately these
  6003. features were implemented in a way incompatible with other archive
  6004. formats.
  6005. Archives in @samp{gnu} format are able to hold pathnames of unlimited
  6006. length.
  6007. @item oldgnu
  6008. Format used by @GNUTAR{} of versions prior to 1.12.
  6009. @item v7
  6010. Archive format, compatible with the V7 implementation of tar. This
  6011. format imposes a number of limitations. The most important of them
  6012. are:
  6013. @enumerate
  6014. @item The maximum length of a file name is limited to 99 characters.
  6015. @item The maximum length of a symbolic link is limited to 99 characters.
  6016. @item It is impossible to store special files (block and character
  6017. devices, fifos etc.)
  6018. @item Maximum value of user or group ID is limited to 2097151 (7777777
  6019. octal)
  6020. @item V7 archives do not contain symbolic ownership information (user
  6021. and group name of the file owner).
  6022. @end enumerate
  6023. This format has traditionally been used by Automake when producing
  6024. Makefiles. This practice will change in the future, in the meantime,
  6025. however this means that projects containing filenames more than 99
  6026. characters long will not be able to use @GNUTAR{} @value{VERSION} and
  6027. Automake prior to 1.9.
  6028. @item ustar
  6029. Archive format defined by @acronym{POSIX.1-1988} specification. It stores
  6030. symbolic ownership information. It is also able to store
  6031. special files. However, it imposes several restrictions as well:
  6032. @enumerate
  6033. @item The maximum length of a file name is limited to 256 characters,
  6034. provided that the filename can be split at directory separator in
  6035. two parts, first of them being at most 155 bytes long. So, in most
  6036. cases the maximum file name length will be shorter than 256
  6037. characters.
  6038. @item The maximum length of a symbolic link name is limited to
  6039. 100 characters.
  6040. @item Maximum size of a file the archive is able to accomodate
  6041. is 8GB
  6042. @item Maximum value of UID/GID is 2097151.
  6043. @item Maximum number of bits in device major and minor numbers is 21.
  6044. @end enumerate
  6045. @item star
  6046. Format used by J@"org Schilling @command{star}
  6047. implementation. @GNUTAR{} is able to read @samp{star} archives but
  6048. currently does not produce them.
  6049. @item posix
  6050. Archive format defined by @acronym{POSIX.1-2001} specification. This is the
  6051. most flexible and feature-rich format. It does not impose any
  6052. restrictions on file sizes or filename lengths. This format is quite
  6053. recent, so not all tar implementations are able to handle it properly.
  6054. However, this format is designed in such a way that any tar
  6055. implementation able to read @samp{ustar} archives will be able to read
  6056. most @samp{posix} archives as well, with the only exception that any
  6057. additional information (such as long file names etc.) will in such
  6058. case be extracted as plain text files along with the files it refers to.
  6059. This archive format will be the default format for future versions
  6060. of @GNUTAR{}.
  6061. @end table
  6062. The following table summarizes the limitations of each of these
  6063. formats:
  6064. @multitable @columnfractions .10 .20 .20 .20 .20
  6065. @headitem Format @tab UID @tab File Size @tab Path Name @tab Devn
  6066. @item gnu @tab 1.8e19 @tab Unlimited @tab Unlimited @tab 63
  6067. @item oldgnu @tab 1.8e19 @tab Unlimited @tab Unlimited @tab 63
  6068. @item v7 @tab 2097151 @tab 8GB @tab 99 @tab n/a
  6069. @item ustar @tab 2097151 @tab 8GB @tab 256 @tab 21
  6070. @item posix @tab Unlimited @tab Unlimited @tab Unlimited @tab Unlimited
  6071. @end multitable
  6072. The default format for @GNUTAR{} is defined at compilation
  6073. time. You may check it by running @command{tar --help}, and examining
  6074. the last lines of its output. Usually, @GNUTAR{} is configured
  6075. to create archives in @samp{gnu} format, however, future version will
  6076. switch to @samp{posix}.
  6077. @menu
  6078. * Portability:: Making @command{tar} Archives More Portable
  6079. * Compression:: Using Less Space through Compression
  6080. * Attributes:: Handling File Attributes
  6081. * Standard:: The Standard Format
  6082. * Extensions:: @acronym{GNU} Extensions to the Archive Format
  6083. * cpio:: Comparison of @command{tar} and @command{cpio}
  6084. @end menu
  6085. @node Portability
  6086. @section Making @command{tar} Archives More Portable
  6087. Creating a @command{tar} archive on a particular system that is meant to be
  6088. useful later on many other machines and with other versions of @command{tar}
  6089. is more challenging than you might think. @command{tar} archive formats
  6090. have been evolving since the first versions of Unix. Many such formats
  6091. are around, and are not always compatible with each other. This section
  6092. discusses a few problems, and gives some advice about making @command{tar}
  6093. archives more portable.
  6094. One golden rule is simplicity. For example, limit your @command{tar}
  6095. archives to contain only regular files and directories, avoiding
  6096. other kind of special files. Do not attempt to save sparse files or
  6097. contiguous files as such. Let's discuss a few more problems, in turn.
  6098. @FIXME{Discuss GNU extensions (incremental backups, multi-volume
  6099. archives and archive labels) in GNU and PAX formats.}
  6100. @menu
  6101. * Portable Names:: Portable Names
  6102. * dereference:: Symbolic Links
  6103. * old:: Old V7 Archives
  6104. * ustar:: Ustar Archives
  6105. * gnu:: GNU and old GNU format archives.
  6106. * posix:: @acronym{POSIX} archives
  6107. * Checksumming:: Checksumming Problems
  6108. * Large or Negative Values:: Large files, negative time stamps, etc.
  6109. @end menu
  6110. @node Portable Names
  6111. @subsection Portable Names
  6112. Use portable file and member names. A name is portable if it contains
  6113. only ASCII letters and digits, @samp{/}, @samp{.}, @samp{_}, and
  6114. @samp{-}; it cannot be empty, start with @samp{-} or @samp{//}, or
  6115. contain @samp{/-}. Avoid deep directory nesting. For portability to
  6116. old Unix hosts, limit your file name components to 14 characters or
  6117. less.
  6118. If you intend to have your @command{tar} archives to be read under
  6119. MSDOS, you should not rely on case distinction for file names, and you
  6120. might use the @acronym{GNU} @command{doschk} program for helping you
  6121. further diagnosing illegal MSDOS names, which are even more limited
  6122. than System V's.
  6123. @node dereference
  6124. @subsection Symbolic Links
  6125. @cindex File names, using symbolic links
  6126. @cindex Symbolic link as file name
  6127. @opindex dereference
  6128. Normally, when @command{tar} archives a symbolic link, it writes a
  6129. block to the archive naming the target of the link. In that way, the
  6130. @command{tar} archive is a faithful record of the file system contents.
  6131. @option{--dereference} (@option{-h}) is used with @option{--create} (@option{-c}), and causes
  6132. @command{tar} to archive the files symbolic links point to, instead of
  6133. the links themselves. When this option is used, when @command{tar}
  6134. encounters a symbolic link, it will archive the linked-to file,
  6135. instead of simply recording the presence of a symbolic link.
  6136. The name under which the file is stored in the file system is not
  6137. recorded in the archive. To record both the symbolic link name and
  6138. the file name in the system, archive the file under both names. If
  6139. all links were recorded automatically by @command{tar}, an extracted file
  6140. might be linked to a file name that no longer exists in the file
  6141. system.
  6142. If a linked-to file is encountered again by @command{tar} while creating
  6143. the same archive, an entire second copy of it will be stored. (This
  6144. @emph{might} be considered a bug.)
  6145. So, for portable archives, do not archive symbolic links as such,
  6146. and use @option{--dereference} (@option{-h}): many systems do not support
  6147. symbolic links, and moreover, your distribution might be unusable if
  6148. it contains unresolved symbolic links.
  6149. @node old
  6150. @subsection Old V7 Archives
  6151. @cindex Format, old style
  6152. @cindex Old style format
  6153. @cindex Old style archives
  6154. @cindex v7 archive format
  6155. Certain old versions of @command{tar} cannot handle additional
  6156. information recorded by newer @command{tar} programs. To create an
  6157. archive in V7 format (not ANSI), which can be read by these old
  6158. versions, specify the @option{--format=v7} option in
  6159. conjunction with the @option{--create} (@option{-c}) (@command{tar} also
  6160. accepts @option{--portability} or @samp{op-old-archive} for this
  6161. option). When you specify it,
  6162. @command{tar} leaves out information about directories, pipes, fifos,
  6163. contiguous files, and device files, and specifies file ownership by
  6164. group and user IDs instead of group and user names.
  6165. When updating an archive, do not use @option{--format=v7}
  6166. unless the archive was created using this option.
  6167. In most cases, a @emph{new} format archive can be read by an @emph{old}
  6168. @command{tar} program without serious trouble, so this option should
  6169. seldom be needed. On the other hand, most modern @command{tar}s are
  6170. able to read old format archives, so it might be safer for you to
  6171. always use @option{--format=v7} for your distributions.
  6172. @node ustar
  6173. @subsection Ustar Archive Format
  6174. @cindex ustar archive format
  6175. Archive format defined by @acronym{POSIX}.1-1988 specification is called
  6176. @code{ustar}. Although it is more flexible than the V7 format, it
  6177. still has many restrictions (@xref{Formats,ustar}, for the detailed
  6178. description of @code{ustar} format). Along with V7 format,
  6179. @code{ustar} format is a good choice for archives intended to be read
  6180. with other implementations of @command{tar}.
  6181. To create archive in @code{ustar} format, use @option{--format=ustar}
  6182. option in conjunction with the @option{--create} (@option{-c}).
  6183. @node gnu
  6184. @subsection @acronym{GNU} and old @GNUTAR{} format
  6185. @cindex GNU archive format
  6186. @cindex Old GNU archive format
  6187. @GNUTAR{} was based on an early draft of the
  6188. @acronym{POSIX} 1003.1 @code{ustar} standard. @acronym{GNU} extensions to
  6189. @command{tar}, such as the support for file names longer than 100
  6190. characters, use portions of the @command{tar} header record which were
  6191. specified in that @acronym{POSIX} draft as unused. Subsequent changes in
  6192. @acronym{POSIX} have allocated the same parts of the header record for
  6193. other purposes. As a result, @GNUTAR{} format is
  6194. incompatible with the current @acronym{POSIX} specification, and with
  6195. @command{tar} programs that follow it.
  6196. In the majority of cases, @command{tar} will be configured to create
  6197. this format by default. This will change in the future releases, since
  6198. we plan to make @samp{posix} format the default.
  6199. To force creation a @GNUTAR{} archive, use option
  6200. @option{--format=gnu}.
  6201. @node posix
  6202. @subsection @GNUTAR{} and @acronym{POSIX} @command{tar}
  6203. @cindex POSIX archive format
  6204. @cindex PAX archive format
  6205. The version @value{VERSION} of @GNUTAR{} is able
  6206. to read and create archives conforming to @acronym{POSIX.1-2001} standard.
  6207. A @acronym{POSIX} conformant archive will be created if @command{tar}
  6208. was given @option{--format=posix} option.
  6209. @node Checksumming
  6210. @subsection Checksumming Problems
  6211. SunOS and HP-UX @command{tar} fail to accept archives created using
  6212. @GNUTAR{} and containing non-ASCII file names, that
  6213. is, file names having characters with the eight bit set, because they
  6214. use signed checksums, while @GNUTAR{} uses unsigned
  6215. checksums while creating archives, as per @acronym{POSIX} standards. On
  6216. reading, @GNUTAR{} computes both checksums and
  6217. accept any. It is somewhat worrying that a lot of people may go
  6218. around doing backup of their files using faulty (or at least
  6219. non-standard) software, not learning about it until it's time to
  6220. restore their missing files with an incompatible file extractor, or
  6221. vice versa.
  6222. @GNUTAR{} compute checksums both ways, and accept
  6223. any on read, so @acronym{GNU} tar can read Sun tapes even with their
  6224. wrong checksums. @GNUTAR{} produces the standard
  6225. checksum, however, raising incompatibilities with Sun. That is to
  6226. say, @GNUTAR{} has not been modified to
  6227. @emph{produce} incorrect archives to be read by buggy @command{tar}'s.
  6228. I've been told that more recent Sun @command{tar} now read standard
  6229. archives, so maybe Sun did a similar patch, after all?
  6230. The story seems to be that when Sun first imported @command{tar}
  6231. sources on their system, they recompiled it without realizing that
  6232. the checksums were computed differently, because of a change in
  6233. the default signing of @code{char}'s in their compiler. So they
  6234. started computing checksums wrongly. When they later realized their
  6235. mistake, they merely decided to stay compatible with it, and with
  6236. themselves afterwards. Presumably, but I do not really know, HP-UX
  6237. has chosen that their @command{tar} archives to be compatible with Sun's.
  6238. The current standards do not favor Sun @command{tar} format. In any
  6239. case, it now falls on the shoulders of SunOS and HP-UX users to get
  6240. a @command{tar} able to read the good archives they receive.
  6241. @node Large or Negative Values
  6242. @subsection Large or Negative Values
  6243. @cindex large values
  6244. @cindex future time stamps
  6245. @cindex negative time stamps
  6246. @UNREVISED{}
  6247. The above sections suggest to use @samp{oldest possible} archive
  6248. format if in doubt. However, sometimes it is not possible. If you
  6249. attempt to archive a file whose metadata cannot be represented using
  6250. required format, @GNUTAR{} will print error message and ignore such a
  6251. file. You will than have to switch to a format that is able to
  6252. handle such values. The format summary table (@pxref{Formats}) will
  6253. help you to do so.
  6254. In particular, when trying to archive files larger than 8GB or with
  6255. timestamps not in the range 1970-01-01 00:00:00 through 2242-03-16
  6256. 12:56:31 @sc{utc}, you will have to chose between @acronym{GNU} and
  6257. @acronym{POSIX} archive formats. When considering which format to
  6258. choose, bear in mind that the @acronym{GNU} format uses
  6259. two's-complement base-256 notation to store values that do not fit
  6260. into standard @acronym{ustar} range. Such archives can generally be
  6261. read only by a @GNUTAR{} implementation. Moreover, they sometimes
  6262. cannot be correctly restored on another hosts even by @GNUTAR{}. For
  6263. example, using two's complement representation for negative time
  6264. stamps that assumes a signed 32-bit @code{time_t} generates archives
  6265. that are not portable to hosts with differing @code{time_t}
  6266. representations.
  6267. On the other hand, @acronym{POSIX} archives, generally speaking, can
  6268. be extracted by any tar implementation that understands older
  6269. @acronym{ustar} format. The only exception are files larger than 8GB.
  6270. @FIXME{Describe how @acronym{POSIX} archives are extracted by non
  6271. POSIX-aware tars.}
  6272. @node Compression
  6273. @section Using Less Space through Compression
  6274. @menu
  6275. * gzip:: Creating and Reading Compressed Archives
  6276. * sparse:: Archiving Sparse Files
  6277. @end menu
  6278. @node gzip
  6279. @subsection Creating and Reading Compressed Archives
  6280. @cindex Compressed archives
  6281. @cindex Storing archives in compressed format
  6282. @GNUTAR{} is able to create and read compressed archives. It supports
  6283. @command{gzip} and @command{bzip2} compression programs. For backward
  6284. compatibilty, it also supports @command{compress} command, although
  6285. we strongly recommend against using it, since there is a patent
  6286. covering the algorithm it uses and you could be sued for patent
  6287. infringement merely by running @command{compress}! Besides, it is less
  6288. effective than @command{gzip} and @command{bzip2}.
  6289. Creating a compressed archive is simple: you just specify a
  6290. @dfn{compression option} along with the usual archive creation
  6291. commands. The compression option is @option{-z} (@option{--gzip}) to
  6292. create a @command{gzip} compressed archive, @option{-j}
  6293. (@option{--bzip2}) to create a @command{bzip2} compressed archive, and
  6294. @option{-Z} (@option{--compress}) to use @command{compress} program.
  6295. For example:
  6296. @smallexample
  6297. $ @kbd{tar cfz archive.tar.gz .}
  6298. @end smallexample
  6299. Reading compressed archive is even simpler: you don't need to specify
  6300. any additional options as @GNUTAR{} recognizes its format
  6301. automatically. Thus, the following commands will list and extract the
  6302. archive created in previous example:
  6303. @smallexample
  6304. # List the compressed archive
  6305. $ @kbd{tar tf archive.tar.gz}
  6306. # Extract the compressed archive
  6307. $ @kbd{tar xf archive.tar.gz}
  6308. @end smallexample
  6309. The only case when you have to specify a decompression option while
  6310. reading the archive is when reading from a pipe or from a tape drive
  6311. that does not support random access. However, in this case @GNUTAR{}
  6312. will indicate which option you should use. For example:
  6313. @smallexample
  6314. $ @kbd{cat archive.tar.gz | tar tf -}
  6315. tar: Archive is compressed. Use -z option
  6316. tar: Error is not recoverable: exiting now
  6317. @end smallexample
  6318. If you see such diagnostics, just add the suggested option to the
  6319. invocation of @GNUTAR{}:
  6320. @smallexample
  6321. $ @kbd{cat archive.tar.gz | tar tfz -}
  6322. @end smallexample
  6323. Notice also, that there are several restrictions on operations on
  6324. compressed archives. First of all, compressed archives cannot be
  6325. modified, i.e., you cannot update (@option{--update} (@option{-u})) them or delete
  6326. (@option{--delete}) members from them. Likewise, you cannot append
  6327. another @command{tar} archive to a compressed archive using
  6328. @option{--append} (@option{-r})). Secondly, multi-volume archives cannot be
  6329. compressed.
  6330. The following table summarizes compression options used by @GNUTAR{}.
  6331. @table @option
  6332. @opindex gzip
  6333. @opindex ungzip
  6334. @item -z
  6335. @itemx --gzip
  6336. @itemx --ungzip
  6337. Filter the archive through @command{gzip}.
  6338. You can use @option{--gzip} and @option{--gunzip} on physical devices
  6339. (tape drives, etc.) and remote files as well as on normal files; data
  6340. to or from such devices or remote files is reblocked by another copy
  6341. of the @command{tar} program to enforce the specified (or default) record
  6342. size. The default compression parameters are used; if you need to
  6343. override them, set @env{GZIP} environment variable, e.g.:
  6344. @smallexample
  6345. $ @kbd{GZIP=--best tar cfz archive.tar.gz subdir}
  6346. @end smallexample
  6347. @noindent
  6348. Another way would be to avoid the @option{--gzip} (@option{--gunzip}, @option{--ungzip}, @option{-z}) option and run
  6349. @command{gzip} explicitly:
  6350. @smallexample
  6351. $ @kbd{tar cf - subdir | gzip --best -c - > archive.tar.gz}
  6352. @end smallexample
  6353. @cindex corrupted archives
  6354. About corrupted compressed archives: @command{gzip}'ed files have no
  6355. redundancy, for maximum compression. The adaptive nature of the
  6356. compression scheme means that the compression tables are implicitly
  6357. spread all over the archive. If you lose a few blocks, the dynamic
  6358. construction of the compression tables becomes unsynchronized, and there
  6359. is little chance that you could recover later in the archive.
  6360. There are pending suggestions for having a per-volume or per-file
  6361. compression in @GNUTAR{}. This would allow for viewing the
  6362. contents without decompression, and for resynchronizing decompression at
  6363. every volume or file, in case of corrupted archives. Doing so, we might
  6364. lose some compressibility. But this would have make recovering easier.
  6365. So, there are pros and cons. We'll see!
  6366. @opindex bzip2
  6367. @item -j
  6368. @itemx --bzip2
  6369. Filter the archive through @code{bzip2}. Otherwise like @option{--gzip}.
  6370. @opindex compress
  6371. @opindex uncompress
  6372. @item -Z
  6373. @itemx --compress
  6374. @itemx --uncompress
  6375. Filter the archive through @command{compress}. Otherwise like @option{--gzip}.
  6376. The @acronym{GNU} Project recommends you not use
  6377. @command{compress}, because there is a patent covering the algorithm it
  6378. uses. You could be sued for patent infringement merely by running
  6379. @command{compress}.
  6380. @opindex use-compress-program
  6381. @item --use-compress-program=@var{prog}
  6382. Use external compression program @var{prog}. Use this option if you
  6383. have a compression program that @GNUTAR{} does not support. There
  6384. are two requirements to which @var{prog} should comply:
  6385. First, when called without options, it should read data from standard
  6386. input, compress it and output it on standard output.
  6387. Secondly, if called with @option{-d} argument, it should do exactly
  6388. the opposite, i.e., read the compressed data from the standard input
  6389. and produce uncompressed data on the standard output.
  6390. @end table
  6391. @cindex gpg, using with tar
  6392. @cindex gnupg, using with tar
  6393. @cindex Using encrypted archives
  6394. The @option{--use-compress-program} option, in particular, lets you
  6395. implement your own filters, not necessarily dealing with
  6396. compression/decomression. For example, suppose you wish to implement
  6397. PGP encryption on top of compression, using @command{gpg} (@pxref{Top,
  6398. gpg, gpg ---- encryption and signing tool, gpg}). The following
  6399. script does that:
  6400. @smallexample
  6401. @group
  6402. #! /bin/sh
  6403. case $1 in
  6404. -d) gpg --decrypt - | gzip -d -c;;
  6405. '') gzip -c | gpg -s ;;
  6406. *) echo "Unknown option $1">&2; exit 1;;
  6407. esac
  6408. @end group
  6409. @end smallexample
  6410. Suppose you name it @file{gpgz} and save it somewhere in your
  6411. @env{PATH}. Then the following command will create a commpressed
  6412. archive signed with your private key:
  6413. @smallexample
  6414. $ @kbd{tar -cf foo.tar.gpgz --use-compress=gpgz .}
  6415. @end smallexample
  6416. @noindent
  6417. Likewise, the following command will list its contents:
  6418. @smallexample
  6419. $ @kbd{tar -tf foo.tar.gpgz --use-compress=gpgz .}
  6420. @end smallexample
  6421. @ignore
  6422. The above is based on the following discussion:
  6423. I have one question, or maybe it's a suggestion if there isn't a way
  6424. to do it now. I would like to use @option{--gzip}, but I'd also like
  6425. the output to be fed through a program like @acronym{GNU}
  6426. @command{ecc} (actually, right now that's @samp{exactly} what I'd like
  6427. to use :-)), basically adding ECC protection on top of compression.
  6428. It seems as if this should be quite easy to do, but I can't work out
  6429. exactly how to go about it. Of course, I can pipe the standard output
  6430. of @command{tar} through @command{ecc}, but then I lose (though I
  6431. haven't started using it yet, I confess) the ability to have
  6432. @command{tar} use @command{rmt} for it's I/O (I think).
  6433. I think the most straightforward thing would be to let me specify a
  6434. general set of filters outboard of compression (preferably ordered,
  6435. so the order can be automatically reversed on input operations, and
  6436. with the options they require specifiable), but beggars shouldn't be
  6437. choosers and anything you decide on would be fine with me.
  6438. By the way, I like @command{ecc} but if (as the comments say) it can't
  6439. deal with loss of block sync, I'm tempted to throw some time at adding
  6440. that capability. Supposing I were to actually do such a thing and
  6441. get it (apparently) working, do you accept contributed changes to
  6442. utilities like that? (Leigh Clayton @file{loc@@soliton.com}, May 1995).
  6443. Isn't that exactly the role of the
  6444. @option{--use-compress-prog=@var{program}} option?
  6445. I never tried it myself, but I suspect you may want to write a
  6446. @var{prog} script or program able to filter stdin to stdout to
  6447. way you want. It should recognize the @option{-d} option, for when
  6448. extraction is needed rather than creation.
  6449. It has been reported that if one writes compressed data (through the
  6450. @option{--gzip} or @option{--compress} options) to a DLT and tries to use
  6451. the DLT compression mode, the data will actually get bigger and one will
  6452. end up with less space on the tape.
  6453. @end ignore
  6454. @node sparse
  6455. @subsection Archiving Sparse Files
  6456. @cindex Sparse Files
  6457. @UNREVISED
  6458. @table @option
  6459. @opindex sparse
  6460. @item -S
  6461. @itemx --sparse
  6462. Handle sparse files efficiently.
  6463. @end table
  6464. This option causes all files to be put in the archive to be tested for
  6465. sparseness, and handled specially if they are. The @option{--sparse}
  6466. (@option{-S}) option is useful when many @code{dbm} files, for example, are being
  6467. backed up. Using this option dramatically decreases the amount of
  6468. space needed to store such a file.
  6469. In later versions, this option may be removed, and the testing and
  6470. treatment of sparse files may be done automatically with any special
  6471. @acronym{GNU} options. For now, it is an option needing to be specified on
  6472. the command line with the creation or updating of an archive.
  6473. Files in the file system occasionally have ``holes.'' A hole in a file
  6474. is a section of the file's contents which was never written. The
  6475. contents of a hole read as all zeros. On many operating systems,
  6476. actual disk storage is not allocated for holes, but they are counted
  6477. in the length of the file. If you archive such a file, @command{tar}
  6478. could create an archive longer than the original. To have @command{tar}
  6479. attempt to recognize the holes in a file, use @option{--sparse} (@option{-S}). When
  6480. you use this option, then, for any file using less disk space than
  6481. would be expected from its length, @command{tar} searches the file for
  6482. consecutive stretches of zeros. It then records in the archive for
  6483. the file where the consecutive stretches of zeros are, and only
  6484. archives the ``real contents'' of the file. On extraction (using
  6485. @option{--sparse} is not needed on extraction) any such
  6486. files have holes created wherever the continuous stretches of zeros
  6487. were found. Thus, if you use @option{--sparse}, @command{tar} archives
  6488. won't take more space than the original.
  6489. A file is sparse if it contains blocks of zeros whose existence is
  6490. recorded, but that have no space allocated on disk. When you specify
  6491. the @option{--sparse} option in conjunction with the @option{--create}
  6492. (@option{-c}) operation, @command{tar} tests all files for sparseness
  6493. while archiving. If @command{tar} finds a file to be sparse, it uses a
  6494. sparse representation of the file in the archive. @xref{create}, for
  6495. more information about creating archives.
  6496. @option{--sparse} is useful when archiving files, such as dbm files,
  6497. likely to contain many nulls. This option dramatically
  6498. decreases the amount of space needed to store such an archive.
  6499. @quotation
  6500. @strong{Please Note:} Always use @option{--sparse} when performing file
  6501. system backups, to avoid archiving the expanded forms of files stored
  6502. sparsely in the system.
  6503. Even if your system has no sparse files currently, some may be
  6504. created in the future. If you use @option{--sparse} while making file
  6505. system backups as a matter of course, you can be assured the archive
  6506. will never take more space on the media than the files take on disk
  6507. (otherwise, archiving a disk filled with sparse files might take
  6508. hundreds of tapes). @xref{Incremental Dumps}.
  6509. @end quotation
  6510. @command{tar} ignores the @option{--sparse} option when reading an archive.
  6511. @table @option
  6512. @item --sparse
  6513. @itemx -S
  6514. Files stored sparsely in the file system are represented sparsely in
  6515. the archive. Use in conjunction with write operations.
  6516. @end table
  6517. However, users should be well aware that at archive creation time,
  6518. @GNUTAR{} still has to read whole disk file to
  6519. locate the @dfn{holes}, and so, even if sparse files use little space
  6520. on disk and in the archive, they may sometimes require inordinate
  6521. amount of time for reading and examining all-zero blocks of a file.
  6522. Although it works, it's painfully slow for a large (sparse) file, even
  6523. though the resulting tar archive may be small. (One user reports that
  6524. dumping a @file{core} file of over 400 megabytes, but with only about
  6525. 3 megabytes of actual data, took about 9 minutes on a Sun Sparcstation
  6526. ELC, with full CPU utilization.)
  6527. This reading is required in all cases and is not related to the fact
  6528. the @option{--sparse} option is used or not, so by merely @emph{not}
  6529. using the option, you are not saving time@footnote{Well! We should say
  6530. the whole truth, here. When @option{--sparse} is selected while creating
  6531. an archive, the current @command{tar} algorithm requires sparse files to be
  6532. read twice, not once. We hope to develop a new archive format for saving
  6533. sparse files in which one pass will be sufficient.}.
  6534. Programs like @command{dump} do not have to read the entire file; by
  6535. examining the file system directly, they can determine in advance
  6536. exactly where the holes are and thus avoid reading through them. The
  6537. only data it need read are the actual allocated data blocks.
  6538. @GNUTAR{} uses a more portable and straightforward
  6539. archiving approach, it would be fairly difficult that it does
  6540. otherwise. Elizabeth Zwicky writes to @file{comp.unix.internals}, on
  6541. 1990-12-10:
  6542. @quotation
  6543. What I did say is that you cannot tell the difference between a hole and an
  6544. equivalent number of nulls without reading raw blocks. @code{st_blocks} at
  6545. best tells you how many holes there are; it doesn't tell you @emph{where}.
  6546. Just as programs may, conceivably, care what @code{st_blocks} is (care
  6547. to name one that does?), they may also care where the holes are (I have
  6548. no examples of this one either, but it's equally imaginable).
  6549. I conclude from this that good archivers are not portable. One can
  6550. arguably conclude that if you want a portable program, you can in good
  6551. conscience restore files with as many holes as possible, since you can't
  6552. get it right.
  6553. @end quotation
  6554. @node Attributes
  6555. @section Handling File Attributes
  6556. @UNREVISED
  6557. When @command{tar} reads files, it updates their access times. To
  6558. avoid this, use the @option{--atime-preserve[=METHOD]} option, which can either
  6559. reset the access time retroactively or avoid changing it in the first
  6560. place.
  6561. Handling of file attributes
  6562. @table @option
  6563. @opindex atime-preserve
  6564. @item --atime-preserve
  6565. @itemx --atime-preserve=replace
  6566. @itemx --atime-preserve=system
  6567. Preserve the access times of files that are read. This works only for
  6568. files that you own, unless you have superuser privileges.
  6569. @option{--atime-preserve=replace} works on most systems, but it also
  6570. restores the data modification time and updates the status change
  6571. time. Hence it doesn't interact with incremental dumps nicely
  6572. (@pxref{Backups}), and it can set access or data modification times
  6573. incorrectly if other programs access the file while @command{tar} is
  6574. running.
  6575. @option{--atime-preserve=system} avoids changing the access time in
  6576. the first place, if the operating system supports this.
  6577. Unfortunately, this may or may not work on any given operating system
  6578. or file system. If @command{tar} knows for sure it won't work, it
  6579. complains right away.
  6580. Currently @option{--atime-preserve} with no operand defaults to
  6581. @option{--atime-preserve=replace}, but this is intended to change to
  6582. @option{--atime-preserve=system} when the latter is better-supported.
  6583. @opindex touch
  6584. @item -m
  6585. @itemx --touch
  6586. Do not extract data modification time.
  6587. When this option is used, @command{tar} leaves the data modification times
  6588. of the files it extracts as the times when the files were extracted,
  6589. instead of setting it to the times recorded in the archive.
  6590. This option is meaningless with @option{--list} (@option{-t}).
  6591. @opindex same-owner
  6592. @item --same-owner
  6593. Create extracted files with the same ownership they have in the
  6594. archive.
  6595. This is the default behavior for the superuser,
  6596. so this option is meaningful only for non-root users, when @command{tar}
  6597. is executed on those systems able to give files away. This is
  6598. considered as a security flaw by many people, at least because it
  6599. makes quite difficult to correctly account users for the disk space
  6600. they occupy. Also, the @code{suid} or @code{sgid} attributes of
  6601. files are easily and silently lost when files are given away.
  6602. When writing an archive, @command{tar} writes the user id and user name
  6603. separately. If it can't find a user name (because the user id is not
  6604. in @file{/etc/passwd}), then it does not write one. When restoring,
  6605. it tries to look the name (if one was written) up in
  6606. @file{/etc/passwd}. If it fails, then it uses the user id stored in
  6607. the archive instead.
  6608. @opindex no-same-owner
  6609. @item --no-same-owner
  6610. @itemx -o
  6611. Do not attempt to restore ownership when extracting. This is the
  6612. default behavior for ordinary users, so this option has an effect
  6613. only for the superuser.
  6614. @opindex numeric-owner
  6615. @item --numeric-owner
  6616. The @option{--numeric-owner} option allows (ANSI) archives to be written
  6617. without user/group name information or such information to be ignored
  6618. when extracting. It effectively disables the generation and/or use
  6619. of user/group name information. This option forces extraction using
  6620. the numeric ids from the archive, ignoring the names.
  6621. This is useful in certain circumstances, when restoring a backup from
  6622. an emergency floppy with different passwd/group files for example.
  6623. It is otherwise impossible to extract files with the right ownerships
  6624. if the password file in use during the extraction does not match the
  6625. one belonging to the file system(s) being extracted. This occurs,
  6626. for example, if you are restoring your files after a major crash and
  6627. had booted from an emergency floppy with no password file or put your
  6628. disk into another machine to do the restore.
  6629. The numeric ids are @emph{always} saved into @command{tar} archives.
  6630. The identifying names are added at create time when provided by the
  6631. system, unless @option{--old-archive} (@option{-o}) is used. Numeric ids could be
  6632. used when moving archives between a collection of machines using
  6633. a centralized management for attribution of numeric ids to users
  6634. and groups. This is often made through using the NIS capabilities.
  6635. When making a @command{tar} file for distribution to other sites, it
  6636. is sometimes cleaner to use a single owner for all files in the
  6637. distribution, and nicer to specify the write permission bits of the
  6638. files as stored in the archive independently of their actual value on
  6639. the file system. The way to prepare a clean distribution is usually
  6640. to have some Makefile rule creating a directory, copying all needed
  6641. files in that directory, then setting ownership and permissions as
  6642. wanted (there are a lot of possible schemes), and only then making a
  6643. @command{tar} archive out of this directory, before cleaning
  6644. everything out. Of course, we could add a lot of options to
  6645. @GNUTAR{} for fine tuning permissions and ownership.
  6646. This is not the good way, I think. @GNUTAR{} is
  6647. already crowded with options and moreover, the approach just explained
  6648. gives you a great deal of control already.
  6649. @opindex same-permissions, short description
  6650. @opindex preserve-permissions, short description
  6651. @item -p
  6652. @itemx --same-permissions
  6653. @itemx --preserve-permissions
  6654. Extract all protection information.
  6655. This option causes @command{tar} to set the modes (access permissions) of
  6656. extracted files exactly as recorded in the archive. If this option
  6657. is not used, the current @code{umask} setting limits the permissions
  6658. on extracted files. This option is by default enabled when
  6659. @command{tar} is executed by a superuser.
  6660. This option is meaningless with @option{--list} (@option{-t}).
  6661. @opindex preserve
  6662. @item --preserve
  6663. Same as both @option{--same-permissions} and @option{--same-order}.
  6664. The @option{--preserve} option has no equivalent short option name.
  6665. It is equivalent to @option{--same-permissions} plus @option{--same-order}.
  6666. @FIXME{I do not see the purpose of such an option. (Neither I. FP.)
  6667. Neither do I. --Sergey}
  6668. @end table
  6669. @node Standard
  6670. @section Basic Tar Format
  6671. @UNREVISED
  6672. While an archive may contain many files, the archive itself is a
  6673. single ordinary file. Like any other file, an archive file can be
  6674. written to a storage device such as a tape or disk, sent through a
  6675. pipe or over a network, saved on the active file system, or even
  6676. stored in another archive. An archive file is not easy to read or
  6677. manipulate without using the @command{tar} utility or Tar mode in
  6678. @acronym{GNU} Emacs.
  6679. Physically, an archive consists of a series of file entries terminated
  6680. by an end-of-archive entry, which consists of two 512 blocks of zero
  6681. bytes. A file
  6682. entry usually describes one of the files in the archive (an
  6683. @dfn{archive member}), and consists of a file header and the contents
  6684. of the file. File headers contain file names and statistics, checksum
  6685. information which @command{tar} uses to detect file corruption, and
  6686. information about file types.
  6687. Archives are permitted to have more than one member with the same
  6688. member name. One way this situation can occur is if more than one
  6689. version of a file has been stored in the archive. For information
  6690. about adding new versions of a file to an archive, see @ref{update}.
  6691. @FIXME-xref{To learn more about having more than one archive member with the
  6692. same name, see -backup node, when it's written.}
  6693. In addition to entries describing archive members, an archive may
  6694. contain entries which @command{tar} itself uses to store information.
  6695. @xref{label}, for an example of such an archive entry.
  6696. A @command{tar} archive file contains a series of blocks. Each block
  6697. contains @code{BLOCKSIZE} bytes. Although this format may be thought
  6698. of as being on magnetic tape, other media are often used.
  6699. Each file archived is represented by a header block which describes
  6700. the file, followed by zero or more blocks which give the contents
  6701. of the file. At the end of the archive file there are two 512-byte blocks
  6702. filled with binary zeros as an end-of-file marker. A reasonable system
  6703. should write such end-of-file marker at the end of an archive, but
  6704. must not assume that such a block exists when reading an archive. In
  6705. particular @GNUTAR{} always issues a warning if it does not encounter it.
  6706. The blocks may be @dfn{blocked} for physical I/O operations.
  6707. Each record of @var{n} blocks (where @var{n} is set by the
  6708. @option{--blocking-factor=@var{512-size}} (@option{-b @var{512-size}}) option to @command{tar}) is written with a single
  6709. @w{@samp{write ()}} operation. On magnetic tapes, the result of
  6710. such a write is a single record. When writing an archive,
  6711. the last record of blocks should be written at the full size, with
  6712. blocks after the zero block containing all zeros. When reading
  6713. an archive, a reasonable system should properly handle an archive
  6714. whose last record is shorter than the rest, or which contains garbage
  6715. records after a zero block.
  6716. The header block is defined in C as follows. In the @GNUTAR{}
  6717. distribution, this is part of file @file{src/tar.h}:
  6718. @smallexample
  6719. @include header.texi
  6720. @end smallexample
  6721. All characters in header blocks are represented by using 8-bit
  6722. characters in the local variant of ASCII. Each field within the
  6723. structure is contiguous; that is, there is no padding used within
  6724. the structure. Each character on the archive medium is stored
  6725. contiguously.
  6726. Bytes representing the contents of files (after the header block
  6727. of each file) are not translated in any way and are not constrained
  6728. to represent characters in any character set. The @command{tar} format
  6729. does not distinguish text files from binary files, and no translation
  6730. of file contents is performed.
  6731. The @code{name}, @code{linkname}, @code{magic}, @code{uname}, and
  6732. @code{gname} are null-terminated character strings. All other fields
  6733. are zero-filled octal numbers in ASCII. Each numeric field of width
  6734. @var{w} contains @var{w} minus 1 digits, and a null.
  6735. The @code{name} field is the file name of the file, with directory names
  6736. (if any) preceding the file name, separated by slashes.
  6737. @FIXME{how big a name before field overflows?}
  6738. The @code{mode} field provides nine bits specifying file permissions
  6739. and three bits to specify the Set UID, Set GID, and Save Text
  6740. (@dfn{sticky}) modes. Values for these bits are defined above.
  6741. When special permissions are required to create a file with a given
  6742. mode, and the user restoring files from the archive does not hold such
  6743. permissions, the mode bit(s) specifying those special permissions
  6744. are ignored. Modes which are not supported by the operating system
  6745. restoring files from the archive will be ignored. Unsupported modes
  6746. should be faked up when creating or updating an archive; e.g., the
  6747. group permission could be copied from the @emph{other} permission.
  6748. The @code{uid} and @code{gid} fields are the numeric user and group
  6749. ID of the file owners, respectively. If the operating system does
  6750. not support numeric user or group IDs, these fields should be ignored.
  6751. The @code{size} field is the size of the file in bytes; linked files
  6752. are archived with this field specified as zero. @FIXME-xref{Modifiers, in
  6753. particular the @option{--incremental} (@option{-G}) option.}
  6754. The @code{mtime} field is the data modification time of the file at
  6755. the time it was archived. It is the ASCII representation of the octal
  6756. value of the last time the file's contents were modified, represented
  6757. as an integer number of
  6758. seconds since January 1, 1970, 00:00 Coordinated Universal Time.
  6759. The @code{chksum} field is the ASCII representation of the octal value
  6760. of the simple sum of all bytes in the header block. Each 8-bit
  6761. byte in the header is added to an unsigned integer, initialized to
  6762. zero, the precision of which shall be no less than seventeen bits.
  6763. When calculating the checksum, the @code{chksum} field is treated as
  6764. if it were all blanks.
  6765. The @code{typeflag} field specifies the type of file archived. If a
  6766. particular implementation does not recognize or permit the specified
  6767. type, the file will be extracted as if it were a regular file. As this
  6768. action occurs, @command{tar} issues a warning to the standard error.
  6769. The @code{atime} and @code{ctime} fields are used in making incremental
  6770. backups; they store, respectively, the particular file's access and
  6771. status change times.
  6772. The @code{offset} is used by the @option{--multi-volume} (@option{-M}) option, when
  6773. making a multi-volume archive. The offset is number of bytes into
  6774. the file that we need to restart at to continue the file on the next
  6775. tape, i.e., where we store the location that a continued file is
  6776. continued at.
  6777. The following fields were added to deal with sparse files. A file
  6778. is @dfn{sparse} if it takes in unallocated blocks which end up being
  6779. represented as zeros, i.e., no useful data. A test to see if a file
  6780. is sparse is to look at the number blocks allocated for it versus the
  6781. number of characters in the file; if there are fewer blocks allocated
  6782. for the file than would normally be allocated for a file of that
  6783. size, then the file is sparse. This is the method @command{tar} uses to
  6784. detect a sparse file, and once such a file is detected, it is treated
  6785. differently from non-sparse files.
  6786. Sparse files are often @code{dbm} files, or other database-type files
  6787. which have data at some points and emptiness in the greater part of
  6788. the file. Such files can appear to be very large when an @samp{ls
  6789. -l} is done on them, when in truth, there may be a very small amount
  6790. of important data contained in the file. It is thus undesirable
  6791. to have @command{tar} think that it must back up this entire file, as
  6792. great quantities of room are wasted on empty blocks, which can lead
  6793. to running out of room on a tape far earlier than is necessary.
  6794. Thus, sparse files are dealt with so that these empty blocks are
  6795. not written to the tape. Instead, what is written to the tape is a
  6796. description, of sorts, of the sparse file: where the holes are, how
  6797. big the holes are, and how much data is found at the end of the hole.
  6798. This way, the file takes up potentially far less room on the tape,
  6799. and when the file is extracted later on, it will look exactly the way
  6800. it looked beforehand. The following is a description of the fields
  6801. used to handle a sparse file:
  6802. The @code{sp} is an array of @code{struct sparse}. Each @code{struct
  6803. sparse} contains two 12-character strings which represent an offset
  6804. into the file and a number of bytes to be written at that offset.
  6805. The offset is absolute, and not relative to the offset in preceding
  6806. array element.
  6807. The header can hold four of these @code{struct sparse} at the moment;
  6808. if more are needed, they are not stored in the header.
  6809. The @code{isextended} flag is set when an @code{extended_header}
  6810. is needed to deal with a file. Note that this means that this flag
  6811. can only be set when dealing with a sparse file, and it is only set
  6812. in the event that the description of the file will not fit in the
  6813. allotted room for sparse structures in the header. In other words,
  6814. an extended_header is needed.
  6815. The @code{extended_header} structure is used for sparse files which
  6816. need more sparse structures than can fit in the header. The header can
  6817. fit 4 such structures; if more are needed, the flag @code{isextended}
  6818. gets set and the next block is an @code{extended_header}.
  6819. Each @code{extended_header} structure contains an array of 21
  6820. sparse structures, along with a similar @code{isextended} flag
  6821. that the header had. There can be an indeterminate number of such
  6822. @code{extended_header}s to describe a sparse file.
  6823. @table @asis
  6824. @item @code{REGTYPE}
  6825. @itemx @code{AREGTYPE}
  6826. These flags represent a regular file. In order to be compatible
  6827. with older versions of @command{tar}, a @code{typeflag} value of
  6828. @code{AREGTYPE} should be silently recognized as a regular file.
  6829. New archives should be created using @code{REGTYPE}. Also, for
  6830. backward compatibility, @command{tar} treats a regular file whose name
  6831. ends with a slash as a directory.
  6832. @item @code{LNKTYPE}
  6833. This flag represents a file linked to another file, of any type,
  6834. previously archived. Such files are identified in Unix by each
  6835. file having the same device and inode number. The linked-to name is
  6836. specified in the @code{linkname} field with a trailing null.
  6837. @item @code{SYMTYPE}
  6838. This represents a symbolic link to another file. The linked-to name
  6839. is specified in the @code{linkname} field with a trailing null.
  6840. @item @code{CHRTYPE}
  6841. @itemx @code{BLKTYPE}
  6842. These represent character special files and block special files
  6843. respectively. In this case the @code{devmajor} and @code{devminor}
  6844. fields will contain the major and minor device numbers respectively.
  6845. Operating systems may map the device specifications to their own
  6846. local specification, or may ignore the entry.
  6847. @item @code{DIRTYPE}
  6848. This flag specifies a directory or sub-directory. The directory
  6849. name in the @code{name} field should end with a slash. On systems where
  6850. disk allocation is performed on a directory basis, the @code{size} field
  6851. will contain the maximum number of bytes (which may be rounded to
  6852. the nearest disk block allocation unit) which the directory may
  6853. hold. A @code{size} field of zero indicates no such limiting. Systems
  6854. which do not support limiting in this manner should ignore the
  6855. @code{size} field.
  6856. @item @code{FIFOTYPE}
  6857. This specifies a FIFO special file. Note that the archiving of a
  6858. FIFO file archives the existence of this file and not its contents.
  6859. @item @code{CONTTYPE}
  6860. This specifies a contiguous file, which is the same as a normal
  6861. file except that, in operating systems which support it, all its
  6862. space is allocated contiguously on the disk. Operating systems
  6863. which do not allow contiguous allocation should silently treat this
  6864. type as a normal file.
  6865. @item @code{A} @dots{} @code{Z}
  6866. These are reserved for custom implementations. Some of these are
  6867. used in the @acronym{GNU} modified format, as described below.
  6868. @end table
  6869. Other values are reserved for specification in future revisions of
  6870. the P1003 standard, and should not be used by any @command{tar} program.
  6871. The @code{magic} field indicates that this archive was output in
  6872. the P1003 archive format. If this field contains @code{TMAGIC},
  6873. the @code{uname} and @code{gname} fields will contain the ASCII
  6874. representation of the owner and group of the file respectively.
  6875. If found, the user and group IDs are used rather than the values in
  6876. the @code{uid} and @code{gid} fields.
  6877. For references, see ISO/IEC 9945-1:1990 or IEEE Std 1003.1-1990, pages
  6878. 169-173 (section 10.1) for @cite{Archive/Interchange File Format}; and
  6879. IEEE Std 1003.2-1992, pages 380-388 (section 4.48) and pages 936-940
  6880. (section E.4.48) for @cite{pax - Portable archive interchange}.
  6881. @node Extensions
  6882. @section @acronym{GNU} Extensions to the Archive Format
  6883. @UNREVISED
  6884. The @acronym{GNU} format uses additional file types to describe new types of
  6885. files in an archive. These are listed below.
  6886. @table @code
  6887. @item GNUTYPE_DUMPDIR
  6888. @itemx 'D'
  6889. This represents a directory and a list of files created by the
  6890. @option{--incremental} (@option{-G}) option. The @code{size} field gives the total
  6891. size of the associated list of files. Each file name is preceded by
  6892. either a @samp{Y} (the file should be in this archive) or an @samp{N}.
  6893. (The file is a directory, or is not stored in the archive.) Each file
  6894. name is terminated by a null. There is an additional null after the
  6895. last file name.
  6896. @item GNUTYPE_MULTIVOL
  6897. @itemx 'M'
  6898. This represents a file continued from another volume of a multi-volume
  6899. archive created with the @option{--multi-volume} (@option{-M}) option. The original
  6900. type of the file is not given here. The @code{size} field gives the
  6901. maximum size of this piece of the file (assuming the volume does
  6902. not end before the file is written out). The @code{offset} field
  6903. gives the offset from the beginning of the file where this part of
  6904. the file begins. Thus @code{size} plus @code{offset} should equal
  6905. the original size of the file.
  6906. @item GNUTYPE_SPARSE
  6907. @itemx 'S'
  6908. This flag indicates that we are dealing with a sparse file. Note
  6909. that archiving a sparse file requires special operations to find
  6910. holes in the file, which mark the positions of these holes, along
  6911. with the number of bytes of data to be found after the hole.
  6912. @item GNUTYPE_VOLHDR
  6913. @itemx 'V'
  6914. This file type is used to mark the volume header that was given with
  6915. the @option{--label=@var{archive-label}} (@option{-V @var{archive-label}}) option when the archive was created. The @code{name}
  6916. field contains the @code{name} given after the @option{--label=@var{archive-label}} (@option{-V @var{archive-label}}) option.
  6917. The @code{size} field is zero. Only the first file in each volume
  6918. of an archive should have this type.
  6919. @end table
  6920. You may have trouble reading a @acronym{GNU} format archive on a
  6921. non-@acronym{GNU} system if the options @option{--incremental} (@option{-G}),
  6922. @option{--multi-volume} (@option{-M}), @option{--sparse} (@option{-S}), or @option{--label=@var{archive-label}} (@option{-V @var{archive-label}}) were
  6923. used when writing the archive. In general, if @command{tar} does not
  6924. use the @acronym{GNU}-added fields of the header, other versions of
  6925. @command{tar} should be able to read the archive. Otherwise, the
  6926. @command{tar} program will give an error, the most likely one being a
  6927. checksum error.
  6928. @node cpio
  6929. @section Comparison of @command{tar} and @command{cpio}
  6930. @UNREVISED
  6931. @FIXME{Reorganize the following material}
  6932. The @command{cpio} archive formats, like @command{tar}, do have maximum
  6933. pathname lengths. The binary and old ASCII formats have a max path
  6934. length of 256, and the new ASCII and CRC ASCII formats have a max
  6935. path length of 1024. @acronym{GNU} @command{cpio} can read and write archives
  6936. with arbitrary pathname lengths, but other @command{cpio} implementations
  6937. may crash unexplainedly trying to read them.
  6938. @command{tar} handles symbolic links in the form in which it comes in BSD;
  6939. @command{cpio} doesn't handle symbolic links in the form in which it comes
  6940. in System V prior to SVR4, and some vendors may have added symlinks
  6941. to their system without enhancing @command{cpio} to know about them.
  6942. Others may have enhanced it in a way other than the way I did it
  6943. at Sun, and which was adopted by AT&T (and which is, I think, also
  6944. present in the @command{cpio} that Berkeley picked up from AT&T and put
  6945. into a later BSD release---I think I gave them my changes).
  6946. (SVR4 does some funny stuff with @command{tar}; basically, its @command{cpio}
  6947. can handle @command{tar} format input, and write it on output, and it
  6948. probably handles symbolic links. They may not have bothered doing
  6949. anything to enhance @command{tar} as a result.)
  6950. @command{cpio} handles special files; traditional @command{tar} doesn't.
  6951. @command{tar} comes with V7, System III, System V, and BSD source;
  6952. @command{cpio} comes only with System III, System V, and later BSD
  6953. (4.3-tahoe and later).
  6954. @command{tar}'s way of handling multiple hard links to a file can handle
  6955. file systems that support 32-bit inumbers (e.g., the BSD file system);
  6956. @command{cpio}s way requires you to play some games (in its "binary"
  6957. format, i-numbers are only 16 bits, and in its "portable ASCII" format,
  6958. they're 18 bits---it would have to play games with the "file system ID"
  6959. field of the header to make sure that the file system ID/i-number pairs
  6960. of different files were always different), and I don't know which
  6961. @command{cpio}s, if any, play those games. Those that don't might get
  6962. confused and think two files are the same file when they're not, and
  6963. make hard links between them.
  6964. @command{tar}s way of handling multiple hard links to a file places only
  6965. one copy of the link on the tape, but the name attached to that copy
  6966. is the @emph{only} one you can use to retrieve the file; @command{cpio}s
  6967. way puts one copy for every link, but you can retrieve it using any
  6968. of the names.
  6969. @quotation
  6970. What type of check sum (if any) is used, and how is this calculated.
  6971. @end quotation
  6972. See the attached manual pages for @command{tar} and @command{cpio} format.
  6973. @command{tar} uses a checksum which is the sum of all the bytes in the
  6974. @command{tar} header for a file; @command{cpio} uses no checksum.
  6975. @quotation
  6976. If anyone knows why @command{cpio} was made when @command{tar} was present
  6977. at the unix scene,
  6978. @end quotation
  6979. It wasn't. @command{cpio} first showed up in PWB/UNIX 1.0; no
  6980. generally-available version of UNIX had @command{tar} at the time. I don't
  6981. know whether any version that was generally available @emph{within AT&T}
  6982. had @command{tar}, or, if so, whether the people within AT&T who did
  6983. @command{cpio} knew about it.
  6984. On restore, if there is a corruption on a tape @command{tar} will stop at
  6985. that point, while @command{cpio} will skip over it and try to restore the
  6986. rest of the files.
  6987. The main difference is just in the command syntax and header format.
  6988. @command{tar} is a little more tape-oriented in that everything is blocked
  6989. to start on a record boundary.
  6990. @quotation
  6991. Is there any differences between the ability to recover crashed
  6992. archives between the two of them. (Is there any chance of recovering
  6993. crashed archives at all.)
  6994. @end quotation
  6995. Theoretically it should be easier under @command{tar} since the blocking
  6996. lets you find a header with some variation of @samp{dd skip=@var{nn}}.
  6997. However, modern @command{cpio}'s and variations have an option to just
  6998. search for the next file header after an error with a reasonable chance
  6999. of resyncing. However, lots of tape driver software won't allow you to
  7000. continue past a media error which should be the only reason for getting
  7001. out of sync unless a file changed sizes while you were writing the
  7002. archive.
  7003. @quotation
  7004. If anyone knows why @command{cpio} was made when @command{tar} was present
  7005. at the unix scene, please tell me about this too.
  7006. @end quotation
  7007. Probably because it is more media efficient (by not blocking everything
  7008. and using only the space needed for the headers where @command{tar}
  7009. always uses 512 bytes per file header) and it knows how to archive
  7010. special files.
  7011. You might want to look at the freely available alternatives. The
  7012. major ones are @command{afio}, @GNUTAR{}, and
  7013. @command{pax}, each of which have their own extensions with some
  7014. backwards compatibility.
  7015. Sparse files were @command{tar}red as sparse files (which you can
  7016. easily test, because the resulting archive gets smaller, and
  7017. @acronym{GNU} @command{cpio} can no longer read it).
  7018. @node Media
  7019. @chapter Tapes and Other Archive Media
  7020. @UNREVISED
  7021. A few special cases about tape handling warrant more detailed
  7022. description. These special cases are discussed below.
  7023. Many complexities surround the use of @command{tar} on tape drives. Since
  7024. the creation and manipulation of archives located on magnetic tape was
  7025. the original purpose of @command{tar}, it contains many features making
  7026. such manipulation easier.
  7027. Archives are usually written on dismountable media---tape cartridges,
  7028. mag tapes, or floppy disks.
  7029. The amount of data a tape or disk holds depends not only on its size,
  7030. but also on how it is formatted. A 2400 foot long reel of mag tape
  7031. holds 40 megabytes of data when formatted at 1600 bits per inch. The
  7032. physically smaller EXABYTE tape cartridge holds 2.3 gigabytes.
  7033. Magnetic media are re-usable---once the archive on a tape is no longer
  7034. needed, the archive can be erased and the tape or disk used over.
  7035. Media quality does deteriorate with use, however. Most tapes or disks
  7036. should be discarded when they begin to produce data errors. EXABYTE
  7037. tape cartridges should be discarded when they generate an @dfn{error
  7038. count} (number of non-usable bits) of more than 10k.
  7039. Magnetic media are written and erased using magnetic fields, and
  7040. should be protected from such fields to avoid damage to stored data.
  7041. Sticking a floppy disk to a filing cabinet using a magnet is probably
  7042. not a good idea.
  7043. @menu
  7044. * Device:: Device selection and switching
  7045. * Remote Tape Server::
  7046. * Common Problems and Solutions::
  7047. * Blocking:: Blocking
  7048. * Many:: Many archives on one tape
  7049. * Using Multiple Tapes:: Using Multiple Tapes
  7050. * label:: Including a Label in the Archive
  7051. * verify::
  7052. * Write Protection::
  7053. @end menu
  7054. @node Device
  7055. @section Device Selection and Switching
  7056. @UNREVISED
  7057. @table @option
  7058. @item -f [@var{hostname}:]@var{file}
  7059. @itemx --file=[@var{hostname}:]@var{file}
  7060. Use archive file or device @var{file} on @var{hostname}.
  7061. @end table
  7062. This option is used to specify the file name of the archive @command{tar}
  7063. works on.
  7064. If the file name is @samp{-}, @command{tar} reads the archive from standard
  7065. input (when listing or extracting), or writes it to standard output
  7066. (when creating). If the @samp{-} file name is given when updating an
  7067. archive, @command{tar} will read the original archive from its standard
  7068. input, and will write the entire new archive to its standard output.
  7069. If the file name contains a @samp{:}, it is interpreted as
  7070. @samp{hostname:file name}. If the @var{hostname} contains an @dfn{at}
  7071. sign (@samp{@@}), it is treated as @samp{user@@hostname:file name}. In
  7072. either case, @command{tar} will invoke the command @command{rsh} (or
  7073. @command{remsh}) to start up an @command{/usr/libexec/rmt} on the remote
  7074. machine. If you give an alternate login name, it will be given to the
  7075. @command{rsh}.
  7076. Naturally, the remote machine must have an executable
  7077. @command{/usr/libexec/rmt}. This program is free software from the
  7078. University of California, and a copy of the source code can be found
  7079. with the sources for @command{tar}; it's compiled and installed by default.
  7080. The exact path to this utility is determined when configuring the package.
  7081. It is @file{@var{prefix}/libexec/rmt}, where @var{prefix} stands for
  7082. your installation prefix. This location may also be overridden at
  7083. runtime by using @option{rmt-command=@var{command}} option (@xref{Option Summary,
  7084. ---rmt-command}, for detailed description of this option. @xref{Remote
  7085. Tape Server}, for the description of @command{rmt} command).
  7086. If this option is not given, but the environment variable @env{TAPE}
  7087. is set, its value is used; otherwise, old versions of @command{tar}
  7088. used a default archive name (which was picked when @command{tar} was
  7089. compiled). The default is normally set up to be the @dfn{first} tape
  7090. drive or other transportable I/O medium on the system.
  7091. Starting with version 1.11.5, @GNUTAR{} uses
  7092. standard input and standard output as the default device, and I will
  7093. not try anymore supporting automatic device detection at installation
  7094. time. This was failing really in too many cases, it was hopeless.
  7095. This is now completely left to the installer to override standard
  7096. input and standard output for default device, if this seems
  7097. preferable. Further, I think @emph{most} actual usages of
  7098. @command{tar} are done with pipes or disks, not really tapes,
  7099. cartridges or diskettes.
  7100. Some users think that using standard input and output is running
  7101. after trouble. This could lead to a nasty surprise on your screen if
  7102. you forget to specify an output file name---especially if you are going
  7103. through a network or terminal server capable of buffering large amounts
  7104. of output. We had so many bug reports in that area of configuring
  7105. default tapes automatically, and so many contradicting requests, that
  7106. we finally consider the problem to be portably intractable. We could
  7107. of course use something like @samp{/dev/tape} as a default, but this
  7108. is @emph{also} running after various kind of trouble, going from hung
  7109. processes to accidental destruction of real tapes. After having seen
  7110. all this mess, using standard input and output as a default really
  7111. sounds like the only clean choice left, and a very useful one too.
  7112. @GNUTAR{} reads and writes archive in records, I
  7113. suspect this is the main reason why block devices are preferred over
  7114. character devices. Most probably, block devices are more efficient
  7115. too. The installer could also check for @samp{DEFTAPE} in
  7116. @file{<sys/mtio.h>}.
  7117. @table @option
  7118. @opindex force-local, short description
  7119. @item --force-local
  7120. Archive file is local even if it contains a colon.
  7121. @opindex rsh-command
  7122. @item --rsh-command=@var{command}
  7123. Use remote @var{command} instead of @command{rsh}. This option exists
  7124. so that people who use something other than the standard @command{rsh}
  7125. (e.g., a Kerberized @command{rsh}) can access a remote device.
  7126. When this command is not used, the shell command found when
  7127. the @command{tar} program was installed is used instead. This is
  7128. the first found of @file{/usr/ucb/rsh}, @file{/usr/bin/remsh},
  7129. @file{/usr/bin/rsh}, @file{/usr/bsd/rsh} or @file{/usr/bin/nsh}.
  7130. The installer may have overridden this by defining the environment
  7131. variable @env{RSH} @emph{at installation time}.
  7132. @item -[0-7][lmh]
  7133. Specify drive and density.
  7134. @opindex multi-volume, short description
  7135. @item -M
  7136. @itemx --multi-volume
  7137. Create/list/extract multi-volume archive.
  7138. This option causes @command{tar} to write a @dfn{multi-volume} archive---one
  7139. that may be larger than will fit on the medium used to hold it.
  7140. @xref{Multi-Volume Archives}.
  7141. @opindex tape-length, short description
  7142. @item -L @var{num}
  7143. @itemx --tape-length=@var{num}
  7144. Change tape after writing @var{num} x 1024 bytes.
  7145. This option might be useful when your tape drivers do not properly
  7146. detect end of physical tapes. By being slightly conservative on the
  7147. maximum tape length, you might avoid the problem entirely.
  7148. @opindex info-script, short description
  7149. @opindex new-volume-script, short description
  7150. @item -F @var{file}
  7151. @itemx --info-script=@var{file}
  7152. @itemx --new-volume-script=@var{file}
  7153. Execute @file{file} at end of each tape. This implies
  7154. @option{--multi-volume} (@option{-M}). @xref{info-script}, for a detailed
  7155. description of this option.
  7156. @end table
  7157. @node Remote Tape Server
  7158. @section The Remote Tape Server
  7159. @cindex remote tape drive
  7160. @pindex rmt
  7161. In order to access the tape drive on a remote machine, @command{tar}
  7162. uses the remote tape server written at the University of California at
  7163. Berkeley. The remote tape server must be installed as
  7164. @file{@var{prefix}/libexec/rmt} on any machine whose tape drive you
  7165. want to use. @command{tar} calls @command{rmt} by running an
  7166. @command{rsh} or @command{remsh} to the remote machine, optionally
  7167. using a different login name if one is supplied.
  7168. A copy of the source for the remote tape server is provided. It is
  7169. Copyright @copyright{} 1983 by the Regents of the University of
  7170. California, but can be freely distributed. It is compiled and
  7171. installed by default.
  7172. @cindex absolute file names
  7173. Unless you use the @option{--absolute-names} (@option{-P}) option,
  7174. @GNUTAR{} will not allow you to create an archive that contains
  7175. absolute file names (a file name beginning with @samp{/}.) If you try,
  7176. @command{tar} will automatically remove the leading @samp{/} from the
  7177. file names it stores in the archive. It will also type a warning
  7178. message telling you what it is doing.
  7179. When reading an archive that was created with a different
  7180. @command{tar} program, @GNUTAR{} automatically
  7181. extracts entries in the archive which have absolute file names as if
  7182. the file names were not absolute. This is an important feature. A
  7183. visitor here once gave a @command{tar} tape to an operator to restore;
  7184. the operator used Sun @command{tar} instead of @GNUTAR{},
  7185. and the result was that it replaced large portions of
  7186. our @file{/bin} and friends with versions from the tape; needless to
  7187. say, we were unhappy about having to recover the file system from
  7188. backup tapes.
  7189. For example, if the archive contained a file @file{/usr/bin/computoy},
  7190. @GNUTAR{} would extract the file to @file{usr/bin/computoy},
  7191. relative to the current directory. If you want to extract the files in
  7192. an archive to the same absolute names that they had when the archive
  7193. was created, you should do a @samp{cd /} before extracting the files
  7194. from the archive, or you should either use the @option{--absolute-names}
  7195. option, or use the command @samp{tar -C / @dots{}}.
  7196. @cindex Ultrix 3.1 and write failure
  7197. Some versions of Unix (Ultrix 3.1 is known to have this problem),
  7198. can claim that a short write near the end of a tape succeeded,
  7199. when it actually failed. This will result in the -M option not
  7200. working correctly. The best workaround at the moment is to use a
  7201. significantly larger blocking factor than the default 20.
  7202. In order to update an archive, @command{tar} must be able to backspace the
  7203. archive in order to reread or rewrite a record that was just read (or
  7204. written). This is currently possible only on two kinds of files: normal
  7205. disk files (or any other file that can be backspaced with @samp{lseek}),
  7206. and industry-standard 9-track magnetic tape (or any other kind of tape
  7207. that can be backspaced with the @code{MTIOCTOP} @code{ioctl}.
  7208. This means that the @option{--append}, @option{--concatenate}, and
  7209. @option{--delete} commands will not work on any other kind of file.
  7210. Some media simply cannot be backspaced, which means these commands and
  7211. options will never be able to work on them. These non-backspacing
  7212. media include pipes and cartridge tape drives.
  7213. Some other media can be backspaced, and @command{tar} will work on them
  7214. once @command{tar} is modified to do so.
  7215. Archives created with the @option{--multi-volume}, @option{--label}, and
  7216. @option{--incremental} (@option{-G}) options may not be readable by other version
  7217. of @command{tar}. In particular, restoring a file that was split over
  7218. a volume boundary will require some careful work with @command{dd}, if
  7219. it can be done at all. Other versions of @command{tar} may also create
  7220. an empty file whose name is that of the volume header. Some versions
  7221. of @command{tar} may create normal files instead of directories archived
  7222. with the @option{--incremental} (@option{-G}) option.
  7223. @node Common Problems and Solutions
  7224. @section Some Common Problems and their Solutions
  7225. @ifclear PUBLISH
  7226. @format
  7227. errors from system:
  7228. permission denied
  7229. no such file or directory
  7230. not owner
  7231. errors from @command{tar}:
  7232. directory checksum error
  7233. header format error
  7234. errors from media/system:
  7235. i/o error
  7236. device busy
  7237. @end format
  7238. @end ifclear
  7239. @node Blocking
  7240. @section Blocking
  7241. @UNREVISED
  7242. @dfn{Block} and @dfn{record} terminology is rather confused, and it
  7243. is also confusing to the expert reader. On the other hand, readers
  7244. who are new to the field have a fresh mind, and they may safely skip
  7245. the next two paragraphs, as the remainder of this manual uses those
  7246. two terms in a quite consistent way.
  7247. John Gilmore, the writer of the public domain @command{tar} from which
  7248. @GNUTAR{} was originally derived, wrote (June 1995):
  7249. @quotation
  7250. The nomenclature of tape drives comes from IBM, where I believe
  7251. they were invented for the IBM 650 or so. On IBM mainframes, what
  7252. is recorded on tape are tape blocks. The logical organization of
  7253. data is into records. There are various ways of putting records into
  7254. blocks, including @code{F} (fixed sized records), @code{V} (variable
  7255. sized records), @code{FB} (fixed blocked: fixed size records, @var{n}
  7256. to a block), @code{VB} (variable size records, @var{n} to a block),
  7257. @code{VSB} (variable spanned blocked: variable sized records that can
  7258. occupy more than one block), etc. The @code{JCL} @samp{DD RECFORM=}
  7259. parameter specified this to the operating system.
  7260. The Unix man page on @command{tar} was totally confused about this.
  7261. When I wrote @code{PD TAR}, I used the historically correct terminology
  7262. (@command{tar} writes data records, which are grouped into blocks).
  7263. It appears that the bogus terminology made it into @acronym{POSIX} (no surprise
  7264. here), and now Fran@,{c}ois has migrated that terminology back
  7265. into the source code too.
  7266. @end quotation
  7267. The term @dfn{physical block} means the basic transfer chunk from or
  7268. to a device, after which reading or writing may stop without anything
  7269. being lost. In this manual, the term @dfn{block} usually refers to
  7270. a disk physical block, @emph{assuming} that each disk block is 512
  7271. bytes in length. It is true that some disk devices have different
  7272. physical blocks, but @command{tar} ignore these differences in its own
  7273. format, which is meant to be portable, so a @command{tar} block is always
  7274. 512 bytes in length, and @dfn{block} always mean a @command{tar} block.
  7275. The term @dfn{logical block} often represents the basic chunk of
  7276. allocation of many disk blocks as a single entity, which the operating
  7277. system treats somewhat atomically; this concept is only barely used
  7278. in @GNUTAR{}.
  7279. The term @dfn{physical record} is another way to speak of a physical
  7280. block, those two terms are somewhat interchangeable. In this manual,
  7281. the term @dfn{record} usually refers to a tape physical block,
  7282. @emph{assuming} that the @command{tar} archive is kept on magnetic tape.
  7283. It is true that archives may be put on disk or used with pipes,
  7284. but nevertheless, @command{tar} tries to read and write the archive one
  7285. @dfn{record} at a time, whatever the medium in use. One record is made
  7286. up of an integral number of blocks, and this operation of putting many
  7287. disk blocks into a single tape block is called @dfn{reblocking}, or
  7288. more simply, @dfn{blocking}. The term @dfn{logical record} refers to
  7289. the logical organization of many characters into something meaningful
  7290. to the application. The term @dfn{unit record} describes a small set
  7291. of characters which are transmitted whole to or by the application,
  7292. and often refers to a line of text. Those two last terms are unrelated
  7293. to what we call a @dfn{record} in @GNUTAR{}.
  7294. When writing to tapes, @command{tar} writes the contents of the archive
  7295. in chunks known as @dfn{records}. To change the default blocking
  7296. factor, use the @option{--blocking-factor=@var{512-size}} (@option{-b
  7297. @var{512-size}}) option. Each record will then be composed of
  7298. @var{512-size} blocks. (Each @command{tar} block is 512 bytes.
  7299. @xref{Standard}.) Each file written to the archive uses at least one
  7300. full record. As a result, using a larger record size can result in
  7301. more wasted space for small files. On the other hand, a larger record
  7302. size can often be read and written much more efficiently.
  7303. Further complicating the problem is that some tape drives ignore the
  7304. blocking entirely. For these, a larger record size can still improve
  7305. performance (because the software layers above the tape drive still
  7306. honor the blocking), but not as dramatically as on tape drives that
  7307. honor blocking.
  7308. When reading an archive, @command{tar} can usually figure out the
  7309. record size on itself. When this is the case, and a non-standard
  7310. record size was used when the archive was created, @command{tar} will
  7311. print a message about a non-standard blocking factor, and then operate
  7312. normally. On some tape devices, however, @command{tar} cannot figure
  7313. out the record size itself. On most of those, you can specify a
  7314. blocking factor (with @option{--blocking-factor}) larger than the
  7315. actual blocking factor, and then use the @option{--read-full-records}
  7316. (@option{-B}) option. (If you specify a blocking factor with
  7317. @option{--blocking-factor} and don't use the
  7318. @option{--read-full-records} option, then @command{tar} will not
  7319. attempt to figure out the recording size itself.) On some devices,
  7320. you must always specify the record size exactly with
  7321. @option{--blocking-factor} when reading, because @command{tar} cannot
  7322. figure it out. In any case, use @option{--list} (@option{-t}) before
  7323. doing any extractions to see whether @command{tar} is reading the archive
  7324. correctly.
  7325. @command{tar} blocks are all fixed size (512 bytes), and its scheme for
  7326. putting them into records is to put a whole number of them (one or
  7327. more) into each record. @command{tar} records are all the same size;
  7328. at the end of the file there's a block containing all zeros, which
  7329. is how you tell that the remainder of the last record(s) are garbage.
  7330. In a standard @command{tar} file (no options), the block size is 512
  7331. and the record size is 10240, for a blocking factor of 20. What the
  7332. @option{--blocking-factor} option does is sets the blocking factor,
  7333. changing the record size while leaving the block size at 512 bytes.
  7334. 20 was fine for ancient 800 or 1600 bpi reel-to-reel tape drives;
  7335. most tape drives these days prefer much bigger records in order to
  7336. stream and not waste tape. When writing tapes for myself, some tend
  7337. to use a factor of the order of 2048, say, giving a record size of
  7338. around one megabyte.
  7339. If you use a blocking factor larger than 20, older @command{tar}
  7340. programs might not be able to read the archive, so we recommend this
  7341. as a limit to use in practice. @GNUTAR{}, however,
  7342. will support arbitrarily large record sizes, limited only by the
  7343. amount of virtual memory or the physical characteristics of the tape
  7344. device.
  7345. @menu
  7346. * Format Variations:: Format Variations
  7347. * Blocking Factor:: The Blocking Factor of an Archive
  7348. @end menu
  7349. @node Format Variations
  7350. @subsection Format Variations
  7351. @cindex Format Parameters
  7352. @cindex Format Options
  7353. @cindex Options, archive format specifying
  7354. @cindex Options, format specifying
  7355. @UNREVISED
  7356. Format parameters specify how an archive is written on the archive
  7357. media. The best choice of format parameters will vary depending on
  7358. the type and number of files being archived, and on the media used to
  7359. store the archive.
  7360. To specify format parameters when accessing or creating an archive,
  7361. you can use the options described in the following sections.
  7362. If you do not specify any format parameters, @command{tar} uses
  7363. default parameters. You cannot modify a compressed archive.
  7364. If you create an archive with the @option{--blocking-factor} option
  7365. specified (@pxref{Blocking Factor}), you must specify that
  7366. blocking-factor when operating on the archive. @xref{Formats}, for other
  7367. examples of format parameter considerations.
  7368. @node Blocking Factor
  7369. @subsection The Blocking Factor of an Archive
  7370. @cindex Blocking Factor
  7371. @cindex Record Size
  7372. @cindex Number of blocks per record
  7373. @cindex Number of bytes per record
  7374. @cindex Bytes per record
  7375. @cindex Blocks per record
  7376. @UNREVISED
  7377. @opindex blocking-factor
  7378. The data in an archive is grouped into blocks, which are 512 bytes.
  7379. Blocks are read and written in whole number multiples called
  7380. @dfn{records}. The number of blocks in a record (ie. the size of a
  7381. record in units of 512 bytes) is called the @dfn{blocking factor}.
  7382. The @option{--blocking-factor=@var{512-size}} (@option{-b
  7383. @var{512-size}}) option specifies the blocking factor of an archive.
  7384. The default blocking factor is typically 20 (i.e., 10240 bytes), but
  7385. can be specified at installation. To find out the blocking factor of
  7386. an existing archive, use @samp{tar --list --file=@var{archive-name}}.
  7387. This may not work on some devices.
  7388. Records are separated by gaps, which waste space on the archive media.
  7389. If you are archiving on magnetic tape, using a larger blocking factor
  7390. (and therefore larger records) provides faster throughput and allows you
  7391. to fit more data on a tape (because there are fewer gaps). If you are
  7392. archiving on cartridge, a very large blocking factor (say 126 or more)
  7393. greatly increases performance. A smaller blocking factor, on the other
  7394. hand, may be useful when archiving small files, to avoid archiving lots
  7395. of nulls as @command{tar} fills out the archive to the end of the record.
  7396. In general, the ideal record size depends on the size of the
  7397. inter-record gaps on the tape you are using, and the average size of the
  7398. files you are archiving. @xref{create}, for information on
  7399. writing archives.
  7400. @FIXME{Need example of using a cartridge with blocking factor=126 or more.}
  7401. Archives with blocking factors larger than 20 cannot be read
  7402. by very old versions of @command{tar}, or by some newer versions
  7403. of @command{tar} running on old machines with small address spaces.
  7404. With @GNUTAR{}, the blocking factor of an archive is limited
  7405. only by the maximum record size of the device containing the archive,
  7406. or by the amount of available virtual memory.
  7407. Also, on some systems, not using adequate blocking factors, as sometimes
  7408. imposed by the device drivers, may yield unexpected diagnostics. For
  7409. example, this has been reported:
  7410. @smallexample
  7411. Cannot write to /dev/dlt: Invalid argument
  7412. @end smallexample
  7413. @noindent
  7414. In such cases, it sometimes happen that the @command{tar} bundled by
  7415. the system is aware of block size idiosyncrasies, while @GNUTAR{}
  7416. requires an explicit specification for the block size,
  7417. which it cannot guess. This yields some people to consider
  7418. @GNUTAR{} is misbehaving, because by comparison,
  7419. @cite{the bundle @command{tar} works OK}. Adding @w{@kbd{-b 256}},
  7420. for example, might resolve the problem.
  7421. If you use a non-default blocking factor when you create an archive, you
  7422. must specify the same blocking factor when you modify that archive. Some
  7423. archive devices will also require you to specify the blocking factor when
  7424. reading that archive, however this is not typically the case. Usually, you
  7425. can use @option{--list} (@option{-t}) without specifying a blocking factor---@command{tar}
  7426. reports a non-default record size and then lists the archive members as
  7427. it would normally. To extract files from an archive with a non-standard
  7428. blocking factor (particularly if you're not sure what the blocking factor
  7429. is), you can usually use the @option{--read-full-records} (@option{-B}) option while
  7430. specifying a blocking factor larger then the blocking factor of the archive
  7431. (ie. @samp{tar --extract --read-full-records --blocking-factor=300}.
  7432. @xref{list}, for more information on the @option{--list} (@option{-t})
  7433. operation. @xref{Reading}, for a more detailed explanation of that option.
  7434. @table @option
  7435. @item --blocking-factor=@var{number}
  7436. @itemx -b @var{number}
  7437. Specifies the blocking factor of an archive. Can be used with any
  7438. operation, but is usually not necessary with @option{--list} (@option{-t}).
  7439. @end table
  7440. Device blocking
  7441. @table @option
  7442. @item -b @var{blocks}
  7443. @itemx --blocking-factor=@var{blocks}
  7444. Set record size to @math{@var{blocks} * 512} bytes.
  7445. This option is used to specify a @dfn{blocking factor} for the archive.
  7446. When reading or writing the archive, @command{tar}, will do reads and writes
  7447. of the archive in records of @math{@var{block}*512} bytes. This is true
  7448. even when the archive is compressed. Some devices requires that all
  7449. write operations be a multiple of a certain size, and so, @command{tar}
  7450. pads the archive out to the next record boundary.
  7451. The default blocking factor is set when @command{tar} is compiled, and is
  7452. typically 20. Blocking factors larger than 20 cannot be read by very
  7453. old versions of @command{tar}, or by some newer versions of @command{tar}
  7454. running on old machines with small address spaces.
  7455. With a magnetic tape, larger records give faster throughput and fit
  7456. more data on a tape (because there are fewer inter-record gaps).
  7457. If the archive is in a disk file or a pipe, you may want to specify
  7458. a smaller blocking factor, since a large one will result in a large
  7459. number of null bytes at the end of the archive.
  7460. When writing cartridge or other streaming tapes, a much larger
  7461. blocking factor (say 126 or more) will greatly increase performance.
  7462. However, you must specify the same blocking factor when reading or
  7463. updating the archive.
  7464. Apparently, Exabyte drives have a physical block size of 8K bytes.
  7465. If we choose our blocksize as a multiple of 8k bytes, then the problem
  7466. seems to disappear. Id est, we are using block size of 112 right
  7467. now, and we haven't had the problem since we switched@dots{}
  7468. With @GNUTAR{} the blocking factor is limited only
  7469. by the maximum record size of the device containing the archive, or by
  7470. the amount of available virtual memory.
  7471. However, deblocking or reblocking is virtually avoided in a special
  7472. case which often occurs in practice, but which requires all the
  7473. following conditions to be simultaneously true:
  7474. @itemize @bullet
  7475. @item
  7476. the archive is subject to a compression option,
  7477. @item
  7478. the archive is not handled through standard input or output, nor
  7479. redirected nor piped,
  7480. @item
  7481. the archive is directly handled to a local disk, instead of any special
  7482. device,
  7483. @item
  7484. @option{--blocking-factor} is not explicitly specified on the @command{tar}
  7485. invocation.
  7486. @end itemize
  7487. If the output goes directly to a local disk, and not through
  7488. stdout, then the last write is not extended to a full record size.
  7489. Otherwise, reblocking occurs. Here are a few other remarks on this
  7490. topic:
  7491. @itemize @bullet
  7492. @item
  7493. @command{gzip} will complain about trailing garbage if asked to
  7494. uncompress a compressed archive on tape, there is an option to turn
  7495. the message off, but it breaks the regularity of simply having to use
  7496. @samp{@var{prog} -d} for decompression. It would be nice if gzip was
  7497. silently ignoring any number of trailing zeros. I'll ask Jean-loup
  7498. Gailly, by sending a copy of this message to him.
  7499. @item
  7500. @command{compress} does not show this problem, but as Jean-loup pointed
  7501. out to Michael, @samp{compress -d} silently adds garbage after
  7502. the result of decompression, which tar ignores because it already
  7503. recognized its end-of-file indicator. So this bug may be safely
  7504. ignored.
  7505. @item
  7506. @samp{gzip -d -q} will be silent about the trailing zeros indeed,
  7507. but will still return an exit status of 2 which tar reports in turn.
  7508. @command{tar} might ignore the exit status returned, but I hate doing
  7509. that, as it weakens the protection @command{tar} offers users against
  7510. other possible problems at decompression time. If @command{gzip} was
  7511. silently skipping trailing zeros @emph{and} also avoiding setting the
  7512. exit status in this innocuous case, that would solve this situation.
  7513. @item
  7514. @command{tar} should become more solid at not stopping to read a pipe at
  7515. the first null block encountered. This inelegantly breaks the pipe.
  7516. @command{tar} should rather drain the pipe out before exiting itself.
  7517. @end itemize
  7518. @opindex ignore-zeros, short description
  7519. @item -i
  7520. @itemx --ignore-zeros
  7521. Ignore blocks of zeros in archive (means EOF).
  7522. The @option{--ignore-zeros} (@option{-i}) option causes @command{tar} to ignore blocks
  7523. of zeros in the archive. Normally a block of zeros indicates the
  7524. end of the archive, but when reading a damaged archive, or one which
  7525. was created by concatenating several archives together, this option
  7526. allows @command{tar} to read the entire archive. This option is not on
  7527. by default because many versions of @command{tar} write garbage after
  7528. the zeroed blocks.
  7529. Note that this option causes @command{tar} to read to the end of the
  7530. archive file, which may sometimes avoid problems when multiple files
  7531. are stored on a single physical tape.
  7532. @opindex read-full-records, short description
  7533. @item -B
  7534. @itemx --read-full-records
  7535. Reblock as we read (for reading 4.2BSD pipes).
  7536. If @option{--read-full-records} is used, @command{tar}
  7537. will not panic if an attempt to read a record from the archive does
  7538. not return a full record. Instead, @command{tar} will keep reading
  7539. until it has obtained a full
  7540. record.
  7541. This option is turned on by default when @command{tar} is reading
  7542. an archive from standard input, or from a remote machine. This is
  7543. because on BSD Unix systems, a read of a pipe will return however
  7544. much happens to be in the pipe, even if it is less than @command{tar}
  7545. requested. If this option was not used, @command{tar} would fail as
  7546. soon as it read an incomplete record from the pipe.
  7547. This option is also useful with the commands for updating an archive.
  7548. @end table
  7549. Tape blocking
  7550. @FIXME{Appropriate options should be moved here from elsewhere.}
  7551. @cindex blocking factor
  7552. @cindex tape blocking
  7553. When handling various tapes or cartridges, you have to take care of
  7554. selecting a proper blocking, that is, the number of disk blocks you
  7555. put together as a single tape block on the tape, without intervening
  7556. tape gaps. A @dfn{tape gap} is a small landing area on the tape
  7557. with no information on it, used for decelerating the tape to a
  7558. full stop, and for later regaining the reading or writing speed.
  7559. When the tape driver starts reading a record, the record has to
  7560. be read whole without stopping, as a tape gap is needed to stop the
  7561. tape motion without loosing information.
  7562. @cindex Exabyte blocking
  7563. @cindex DAT blocking
  7564. Using higher blocking (putting more disk blocks per tape block) will use
  7565. the tape more efficiently as there will be less tape gaps. But reading
  7566. such tapes may be more difficult for the system, as more memory will be
  7567. required to receive at once the whole record. Further, if there is a
  7568. reading error on a huge record, this is less likely that the system will
  7569. succeed in recovering the information. So, blocking should not be too
  7570. low, nor it should be too high. @command{tar} uses by default a blocking of
  7571. 20 for historical reasons, and it does not really matter when reading or
  7572. writing to disk. Current tape technology would easily accommodate higher
  7573. blockings. Sun recommends a blocking of 126 for Exabytes and 96 for DATs.
  7574. We were told that for some DLT drives, the blocking should be a multiple
  7575. of 4Kb, preferably 64Kb (@w{@kbd{-b 128}}) or 256 for decent performance.
  7576. Other manufacturers may use different recommendations for the same tapes.
  7577. This might also depends of the buffering techniques used inside modern
  7578. tape controllers. Some imposes a minimum blocking, or a maximum blocking.
  7579. Others request blocking to be some exponent of two.
  7580. So, there is no fixed rule for blocking. But blocking at read time
  7581. should ideally be the same as blocking used at write time. At one place
  7582. I know, with a wide variety of equipment, they found it best to use a
  7583. blocking of 32 to guarantee that their tapes are fully interchangeable.
  7584. I was also told that, for recycled tapes, prior erasure (by the same
  7585. drive unit that will be used to create the archives) sometimes lowers
  7586. the error rates observed at rewriting time.
  7587. I might also use @option{--number-blocks} instead of
  7588. @option{--block-number}, so @option{--block} will then expand to
  7589. @option{--blocking-factor} unambiguously.
  7590. @node Many
  7591. @section Many Archives on One Tape
  7592. @FIXME{Appropriate options should be moved here from elsewhere.}
  7593. @findex ntape @r{device}
  7594. Most tape devices have two entries in the @file{/dev} directory, or
  7595. entries that come in pairs, which differ only in the minor number for
  7596. this device. Let's take for example @file{/dev/tape}, which often
  7597. points to the only or usual tape device of a given system. There might
  7598. be a corresponding @file{/dev/nrtape} or @file{/dev/ntape}. The simpler
  7599. name is the @emph{rewinding} version of the device, while the name
  7600. having @samp{nr} in it is the @emph{no rewinding} version of the same
  7601. device.
  7602. A rewinding tape device will bring back the tape to its beginning point
  7603. automatically when this device is opened or closed. Since @command{tar}
  7604. opens the archive file before using it and closes it afterwards, this
  7605. means that a simple:
  7606. @smallexample
  7607. $ @kbd{tar cf /dev/tape @var{directory}}
  7608. @end smallexample
  7609. @noindent
  7610. will reposition the tape to its beginning both prior and after saving
  7611. @var{directory} contents to it, thus erasing prior tape contents and
  7612. making it so that any subsequent write operation will destroy what has
  7613. just been saved.
  7614. @cindex tape positioning
  7615. So, a rewinding device is normally meant to hold one and only one file.
  7616. If you want to put more than one @command{tar} archive on a given tape, you
  7617. will need to avoid using the rewinding version of the tape device. You
  7618. will also have to pay special attention to tape positioning. Errors in
  7619. positioning may overwrite the valuable data already on your tape. Many
  7620. people, burnt by past experiences, will only use rewinding devices and
  7621. limit themselves to one file per tape, precisely to avoid the risk of
  7622. such errors. Be fully aware that writing at the wrong position on a
  7623. tape loses all information past this point and most probably until the
  7624. end of the tape, and this destroyed information @emph{cannot} be
  7625. recovered.
  7626. To save @var{directory-1} as a first archive at the beginning of a
  7627. tape, and leave that tape ready for a second archive, you should use:
  7628. @smallexample
  7629. $ @kbd{mt -f /dev/nrtape rewind}
  7630. $ @kbd{tar cf /dev/nrtape @var{directory-1}}
  7631. @end smallexample
  7632. @cindex tape marks
  7633. @dfn{Tape marks} are special magnetic patterns written on the tape
  7634. media, which are later recognizable by the reading hardware. These
  7635. marks are used after each file, when there are many on a single tape.
  7636. An empty file (that is to say, two tape marks in a row) signal the
  7637. logical end of the tape, after which no file exist. Usually,
  7638. non-rewinding tape device drivers will react to the close request issued
  7639. by @command{tar} by first writing two tape marks after your archive, and by
  7640. backspacing over one of these. So, if you remove the tape at that time
  7641. from the tape drive, it is properly terminated. But if you write
  7642. another file at the current position, the second tape mark will be
  7643. erased by the new information, leaving only one tape mark between files.
  7644. So, you may now save @var{directory-2} as a second archive after the
  7645. first on the same tape by issuing the command:
  7646. @smallexample
  7647. $ @kbd{tar cf /dev/nrtape @var{directory-2}}
  7648. @end smallexample
  7649. @noindent
  7650. and so on for all the archives you want to put on the same tape.
  7651. Another usual case is that you do not write all the archives the same
  7652. day, and you need to remove and store the tape between two archive
  7653. sessions. In general, you must remember how many files are already
  7654. saved on your tape. Suppose your tape already has 16 files on it, and
  7655. that you are ready to write the 17th. You have to take care of skipping
  7656. the first 16 tape marks before saving @var{directory-17}, say, by using
  7657. these commands:
  7658. @smallexample
  7659. $ @kbd{mt -f /dev/nrtape rewind}
  7660. $ @kbd{mt -f /dev/nrtape fsf 16}
  7661. $ @kbd{tar cf /dev/nrtape @var{directory-17}}
  7662. @end smallexample
  7663. In all the previous examples, we put aside blocking considerations, but
  7664. you should do the proper things for that as well. @xref{Blocking}.
  7665. @menu
  7666. * Tape Positioning:: Tape Positions and Tape Marks
  7667. * mt:: The @command{mt} Utility
  7668. @end menu
  7669. @node Tape Positioning
  7670. @subsection Tape Positions and Tape Marks
  7671. @UNREVISED
  7672. Just as archives can store more than one file from the file system,
  7673. tapes can store more than one archive file. To keep track of where
  7674. archive files (or any other type of file stored on tape) begin and
  7675. end, tape archive devices write magnetic @dfn{tape marks} on the
  7676. archive media. Tape drives write one tape mark between files,
  7677. two at the end of all the file entries.
  7678. If you think of data as a series of records "rrrr"'s, and tape marks as
  7679. "*"'s, a tape might look like the following:
  7680. @smallexample
  7681. rrrr*rrrrrr*rrrrr*rr*rrrrr**-------------------------
  7682. @end smallexample
  7683. Tape devices read and write tapes using a read/write @dfn{tape
  7684. head}---a physical part of the device which can only access one
  7685. point on the tape at a time. When you use @command{tar} to read or
  7686. write archive data from a tape device, the device will begin reading
  7687. or writing from wherever on the tape the tape head happens to be,
  7688. regardless of which archive or what part of the archive the tape
  7689. head is on. Before writing an archive, you should make sure that no
  7690. data on the tape will be overwritten (unless it is no longer needed).
  7691. Before reading an archive, you should make sure the tape head is at
  7692. the beginning of the archive you want to read. You can do it manually
  7693. via @code{mt} utility (@pxref{mt}). The @code{restore} script does
  7694. that automatically (@pxref{Scripted Restoration}).
  7695. If you want to add new archive file entries to a tape, you should
  7696. advance the tape to the end of the existing file entries, backspace
  7697. over the last tape mark, and write the new archive file. If you were
  7698. to add two archives to the example above, the tape might look like the
  7699. following:
  7700. @smallexample
  7701. rrrr*rrrrrr*rrrrr*rr*rrrrr*rrr*rrrr**----------------
  7702. @end smallexample
  7703. @node mt
  7704. @subsection The @command{mt} Utility
  7705. @UNREVISED
  7706. @FIXME{Is it true that this only works on non-block devices?
  7707. should explain the difference, (fixed or variable).}
  7708. @xref{Blocking Factor}.
  7709. You can use the @command{mt} utility to advance or rewind a tape past a
  7710. specified number of archive files on the tape. This will allow you
  7711. to move to the beginning of an archive before extracting or reading
  7712. it, or to the end of all the archives before writing a new one.
  7713. @FIXME{Why isn't there an "advance 'til you find two tape marks
  7714. together"?}
  7715. The syntax of the @command{mt} command is:
  7716. @smallexample
  7717. @kbd{mt [-f @var{tapename}] @var{operation} [@var{number}]}
  7718. @end smallexample
  7719. where @var{tapename} is the name of the tape device, @var{number} is
  7720. the number of times an operation is performed (with a default of one),
  7721. and @var{operation} is one of the following:
  7722. @FIXME{is there any use for record operations?}
  7723. @table @option
  7724. @item eof
  7725. @itemx weof
  7726. Writes @var{number} tape marks at the current position on the tape.
  7727. @item fsf
  7728. Moves tape position forward @var{number} files.
  7729. @item bsf
  7730. Moves tape position back @var{number} files.
  7731. @item rewind
  7732. Rewinds the tape. (Ignores @var{number}).
  7733. @item offline
  7734. @itemx rewoff1
  7735. Rewinds the tape and takes the tape device off-line. (Ignores @var{number}).
  7736. @item status
  7737. Prints status information about the tape unit.
  7738. @end table
  7739. @FIXME{Is there a better way to frob the spacing on the list?}
  7740. If you don't specify a @var{tapename}, @command{mt} uses the environment
  7741. variable @env{TAPE}; if @env{TAPE} is not set, @command{mt} will use
  7742. the default device specified in your @file{sys/mtio.h} file
  7743. (@code{DEFTAPE} variable). If this is not defined, the program will
  7744. display a descriptive error message and exit with code 1.
  7745. @command{mt} returns a 0 exit status when the operation(s) were
  7746. successful, 1 if the command was unrecognized, and 2 if an operation
  7747. failed.
  7748. @node Using Multiple Tapes
  7749. @section Using Multiple Tapes
  7750. @UNREVISED
  7751. Often you might want to write a large archive, one larger than will fit
  7752. on the actual tape you are using. In such a case, you can run multiple
  7753. @command{tar} commands, but this can be inconvenient, particularly if you
  7754. are using options like @option{--exclude=@var{pattern}} or dumping entire file systems.
  7755. Therefore, @command{tar} supports multiple tapes automatically.
  7756. Use @option{--multi-volume} (@option{-M}) on the command line, and
  7757. then @command{tar} will, when it reaches the end of the tape, prompt
  7758. for another tape, and continue the archive. Each tape will have an
  7759. independent archive, and can be read without needing the other. (As
  7760. an exception to this, the file that @command{tar} was archiving when
  7761. it ran out of tape will usually be split between the two archives; in
  7762. this case you need to extract from the first archive, using
  7763. @option{--multi-volume}, and then put in the second tape when
  7764. prompted, so @command{tar} can restore both halves of the file.)
  7765. @GNUTAR{} multi-volume archives do not use a truly portable format.
  7766. You need @GNUTAR{} at both ends to process them properly.
  7767. When prompting for a new tape, @command{tar} accepts any of the following
  7768. responses:
  7769. @table @kbd
  7770. @item ?
  7771. Request @command{tar} to explain possible responses
  7772. @item q
  7773. Request @command{tar} to exit immediately.
  7774. @item n @var{file-name}
  7775. Request @command{tar} to write the next volume on the file @var{file-name}.
  7776. @item !
  7777. Request @command{tar} to run a subshell. This option can be disabled
  7778. by giving @option{--restrict} command line option to @command{tar}.
  7779. @item y
  7780. Request @command{tar} to begin writing the next volume.
  7781. @end table
  7782. (You should only type @samp{y} after you have changed the tape;
  7783. otherwise @command{tar} will write over the volume it just finished.)
  7784. @cindex End-of-archive info script
  7785. @cindex Info script
  7786. @anchor{info-script}
  7787. @opindex info-script
  7788. @opindex new-volume-script
  7789. If you want more elaborate behavior than this, give @command{tar} the
  7790. @option{--info-script=@var{script-name}}
  7791. (@option{--new-volume-script=@var{script-name}}, @option{-F
  7792. @var{script-name}}) option. The file @var{script-name} is expected to
  7793. be a program (or shell script) to be run instead of the normal
  7794. prompting procedure. It is executed without any command line
  7795. arguments. Additional data is passed to it via the following
  7796. environment variables:
  7797. @table @env
  7798. @vrindex TAR_VERSION, info script environment variable
  7799. @item TAR_VERSION
  7800. @GNUTAR{} version number.
  7801. @vrindex TAR_ARCHIVE, info script environment variable
  7802. @item TAR_ARCHIVE
  7803. The name of the archive @command{tar} is processing.
  7804. @vrindex TAR_VOLUME, info script environment variable
  7805. @item TAR_VOLUME
  7806. Ordinal number of the volume @command{tar} is about to start.
  7807. @vrindex TAR_SUBCOMMAND, info script environment variable
  7808. @item TAR_SUBCOMMAND
  7809. Short option describing the operation @command{tar} is executed.
  7810. @xref{Operations}, for a complete list of subcommand options.
  7811. @vrindex TAR_FORMAT, info script environment variable
  7812. @item TAR_FORMAT
  7813. Format of the archive being processed. @xref{Formats}, for a complete
  7814. list of archive format names.
  7815. @end table
  7816. The info script can instruct @command{tar} to use new archive name,
  7817. by writing in to file descriptor 3 (see below for an
  7818. example).
  7819. If the info script fails, @command{tar} exits; otherwise, it begins
  7820. writing the next volume.
  7821. The method @command{tar} uses to detect end of tape is not perfect, and
  7822. fails on some operating systems or on some devices. You can use the
  7823. @option{--tape-length=@var{size}} (@option{-L @var{size}}) option if
  7824. @command{tar} can't detect the end of the tape itself. This option
  7825. selects @option{--multi-volume} (@option{-M}) automatically. The
  7826. @var{size} argument should then be the usable size of the tape in
  7827. units of 1024 bytes. But for many devices, and floppy disks in
  7828. particular, this option is never required for real, as far as we know.
  7829. @cindex Volume number file
  7830. @cindex volno file
  7831. @anchor{volno-file}
  7832. @opindex volno-file
  7833. The volume number used by @command{tar} in its tape-change prompt
  7834. can be changed; if you give the
  7835. @option{--volno-file=@var{file-of-number}} option, then
  7836. @var{file-of-number} should be an unexisting file to be created, or
  7837. else, a file already containing a decimal number. That number will be
  7838. used as the volume number of the first volume written. When
  7839. @command{tar} is finished, it will rewrite the file with the
  7840. now-current volume number. (This does not change the volume number
  7841. written on a tape label, as per @ref{label}, it @emph{only} affects
  7842. the number used in the prompt.)
  7843. If you want @command{tar} to cycle through a series of files or tape
  7844. drives, there are three approaches to choose from. First of all, you
  7845. can give @command{tar} multiple @option{--file} options. In this case
  7846. the specified files will be used, in sequence, as the successive
  7847. volumes of the archive. Only when the first one in the sequence needs
  7848. to be used again will @command{tar} prompt for a tape change (or run
  7849. the info script). Secondly, you can use the @samp{n} response to the
  7850. tape-change prompt, and, finally, you can use an info script, that
  7851. writes new archive name to file descriptor. The following example
  7852. illustrates this approach:
  7853. @smallexample
  7854. @group
  7855. #! /bin/sh
  7856. echo Preparing volume $TAR_VOLUME of $TAR_ARCHIVE.
  7857. name=`expr $TAR_ARCHIVE : '\(.*\)-.*'`
  7858. case $TAR_SUBCOMMAND in
  7859. -c) ;;
  7860. -d|-x|-t) test -r $@{name:-$TAR_ARCHIVE@}-$TAR_VOLUME || exit 1
  7861. ;;
  7862. *) exit 1
  7863. esac
  7864. echo $@{name:-$TAR_ARCHIVE@}-$TAR_VOLUME >&3
  7865. @end group
  7866. @end smallexample
  7867. Each volume of a multi-volume archive is an independent @command{tar}
  7868. archive, complete in itself. For example, you can list or extract any
  7869. volume alone; just don't specify @option{--multi-volume}
  7870. (@option{-M}). However, if one file in the archive is split across
  7871. volumes, the only way to extract it successfully is with a
  7872. multi-volume extract command @option{--extract --multi-volume}
  7873. (@option{-xM}) starting on or before the volume where the file begins.
  7874. For example, let's presume someone has two tape drives on a system
  7875. named @file{/dev/tape0} and @file{/dev/tape1}. For having @GNUTAR{}
  7876. to switch to the second drive when it needs to write the
  7877. second tape, and then back to the first tape, etc., just do either of:
  7878. @smallexample
  7879. $ @kbd{tar --create --multi-volume --file=/dev/tape0 --file=/dev/tape1 @var{files}}
  7880. $ @kbd{tar cMff /dev/tape0 /dev/tape1 @var{files}}
  7881. @end smallexample
  7882. @menu
  7883. * Multi-Volume Archives:: Archives Longer than One Tape or Disk
  7884. * Tape Files:: Tape Files
  7885. * Tarcat:: Concatenate Volumes into a Single Archive
  7886. @end menu
  7887. @node Multi-Volume Archives
  7888. @subsection Archives Longer than One Tape or Disk
  7889. @cindex Multi-volume archives
  7890. @UNREVISED
  7891. @opindex multi-volume
  7892. To create an archive that is larger than will fit on a single unit of
  7893. the media, use the @option{--multi-volume} (@option{-M}) option in conjunction with
  7894. the @option{--create} option (@pxref{create}). A @dfn{multi-volume}
  7895. archive can be manipulated like any other archive (provided the
  7896. @option{--multi-volume} option is specified), but is stored on more
  7897. than one tape or disk.
  7898. When you specify @option{--multi-volume}, @command{tar} does not report an
  7899. error when it comes to the end of an archive volume (when reading), or
  7900. the end of the media (when writing). Instead, it prompts you to load
  7901. a new storage volume. If the archive is on a magnetic tape, you
  7902. should change tapes when you see the prompt; if the archive is on a
  7903. floppy disk, you should change disks; etc.
  7904. You can read each individual volume of a multi-volume archive as if it
  7905. were an archive by itself. For example, to list the contents of one
  7906. volume, use @option{--list}, without @option{--multi-volume} specified.
  7907. To extract an archive member from one volume (assuming it is described
  7908. that volume), use @option{--extract}, again without
  7909. @option{--multi-volume}.
  7910. If an archive member is split across volumes (ie. its entry begins on
  7911. one volume of the media and ends on another), you need to specify
  7912. @option{--multi-volume} to extract it successfully. In this case, you
  7913. should load the volume where the archive member starts, and use
  7914. @samp{tar --extract --multi-volume}---@command{tar} will prompt for later
  7915. volumes as it needs them. @xref{extracting archives}, for more
  7916. information about extracting archives.
  7917. @option{--info-script=@var{script-name}}
  7918. (@option{--new-volume-script=@var{script-name}}, @option{-F
  7919. @var{script-name}}) (@pxref{info-script}) is like
  7920. @option{--multi-volume} (@option{-M}), except that @command{tar} does
  7921. not prompt you directly to change media volumes when a volume is
  7922. full---instead, @command{tar} runs commands you have stored in
  7923. @var{script-name}. For example, this option can be used to eject
  7924. cassettes, or to broadcast messages such as @samp{Someone please come
  7925. change my tape} when performing unattended backups. When
  7926. @var{script-name} is done, @command{tar} will assume that the media
  7927. has been changed.
  7928. Multi-volume archives can be modified like any other archive. To add
  7929. files to a multi-volume archive, you need to only mount the last
  7930. volume of the archive media (and new volumes, if needed). For all
  7931. other operations, you need to use the entire archive.
  7932. If a multi-volume archive was labeled using
  7933. @option{--label=@var{archive-label}} (@option{-V @var{archive-label}})
  7934. (@pxref{label}) when it was created, @command{tar} will not
  7935. automatically label volumes which are added later. To label
  7936. subsequent volumes, specify @option{--label=@var{archive-label}} again
  7937. in conjunction with the @option{--append}, @option{--update} or
  7938. @option{--concatenate} operation.
  7939. @cindex Labeling multi-volume archives
  7940. @FIXME{example}
  7941. @FIXME{There should be a sample program here, including an exit
  7942. before end. Is the exit status even checked in tar? :-(}
  7943. @table @option
  7944. @item --multi-volume
  7945. @itemx -M
  7946. Creates a multi-volume archive, when used in conjunction with
  7947. @option{--create} (@option{-c}). To perform any other operation on a multi-volume
  7948. archive, specify @option{--multi-volume} in conjunction with that
  7949. operation.
  7950. @item --info-script=@var{program-file}
  7951. @itemx --new-volume-script=@var{program-file}
  7952. @itemx -F @var{program-file}
  7953. Creates a multi-volume archive via a script. Used in conjunction with
  7954. @option{--create} (@option{-c}). @xref{info-script}, dor a detailed discussion.
  7955. @end table
  7956. Beware that there is @emph{no} real standard about the proper way, for
  7957. a @command{tar} archive, to span volume boundaries. If you have a
  7958. multi-volume created by some vendor's @command{tar}, there is almost
  7959. no chance you could read all the volumes with @GNUTAR{}.
  7960. The converse is also true: you may not expect
  7961. multi-volume archives created by @GNUTAR{} to be
  7962. fully recovered by vendor's @command{tar}. Since there is little
  7963. chance that, in mixed system configurations, some vendor's
  7964. @command{tar} will work on another vendor's machine, and there is a
  7965. great chance that @GNUTAR{} will work on most of
  7966. them, your best bet is to install @GNUTAR{} on all
  7967. machines between which you know exchange of files is possible.
  7968. @node Tape Files
  7969. @subsection Tape Files
  7970. @UNREVISED
  7971. To give the archive a name which will be recorded in it, use the
  7972. @option{--label=@var{volume-label}} (@option{-V @var{volume-label}})
  7973. option. This will write a special block identifying
  7974. @var{volume-label} as the name of the archive to the front of the
  7975. archive which will be displayed when the archive is listed with
  7976. @option{--list}. If you are creating a multi-volume archive with
  7977. @option{--multi-volume} (@pxref{Using Multiple Tapes}), then the
  7978. volume label will have @samp{Volume @var{nnn}} appended to the name
  7979. you give, where @var{nnn} is the number of the volume of the archive.
  7980. (If you use the @option{--label=@var{volume-label}}) option when
  7981. reading an archive, it checks to make sure the label on the tape
  7982. matches the one you give. @xref{label}.
  7983. When @command{tar} writes an archive to tape, it creates a single
  7984. tape file. If multiple archives are written to the same tape, one
  7985. after the other, they each get written as separate tape files. When
  7986. extracting, it is necessary to position the tape at the right place
  7987. before running @command{tar}. To do this, use the @command{mt} command.
  7988. For more information on the @command{mt} command and on the organization
  7989. of tapes into a sequence of tape files, see @ref{mt}.
  7990. People seem to often do:
  7991. @smallexample
  7992. @kbd{--label="@var{some-prefix} `date +@var{some-format}`"}
  7993. @end smallexample
  7994. or such, for pushing a common date in all volumes or an archive set.
  7995. @node Tarcat
  7996. @subsection Concatenate Volumes into a Single Archive
  7997. @pindex tarcat
  7998. Sometimes it is necessary to convert existing @GNUTAR{} multi-volume
  7999. archive to a single @command{tar} archive. Simply concatenating all
  8000. volumes into one will not work, since each volume carries an additional
  8001. information at the beginning. @GNUTAR{} is shipped with the shell
  8002. script @command{tarcat} designed for this purpose.
  8003. The script takes a list of files comprising a multi-volume archive
  8004. and creates the resulting archive at the standard output. For example:
  8005. @smallexample
  8006. @kbd{tarcat vol.1 vol.2 vol.3 | tar tf -}
  8007. @end smallexample
  8008. The script implements a simple heuristics to determine the format of
  8009. the first volume file and to decide how to process the rest of the
  8010. files. However, it makes no attempt to verify whether the files are
  8011. given in order or even if they are valid @command{tar} archives.
  8012. It uses @command{dd} and does not filter its standard error, so you
  8013. will usually see lots of spurious messages.
  8014. @FIXME{The script is not installed. Should we install it?}
  8015. @node label
  8016. @section Including a Label in the Archive
  8017. @cindex Labeling an archive
  8018. @cindex Labels on the archive media
  8019. @UNREVISED
  8020. @opindex label
  8021. To avoid problems caused by misplaced paper labels on the archive
  8022. media, you can include a @dfn{label} entry---an archive member which
  8023. contains the name of the archive---in the archive itself. Use the
  8024. @option{--label=@var{archive-label}} (@option{-V @var{archive-label}})
  8025. option in conjunction with the @option{--create} operation to include
  8026. a label entry in the archive as it is being created.
  8027. @table @option
  8028. @item --label=@var{archive-label}
  8029. @itemx -V @var{archive-label}
  8030. Includes an @dfn{archive-label} at the beginning of the archive when
  8031. the archive is being created, when used in conjunction with the
  8032. @option{--create} operation. Checks to make sure the archive label
  8033. matches the one specified (when used in conjunction with any other
  8034. operation.
  8035. @end table
  8036. If you create an archive using both
  8037. @option{--label=@var{archive-label}} (@option{-V @var{archive-label}})
  8038. and @option{--multi-volume} (@option{-M}), each volume of the archive
  8039. will have an archive label of the form @samp{@var{archive-label}
  8040. Volume @var{n}}, where @var{n} is 1 for the first volume, 2 for the
  8041. next, and so on. @xref{Using Multiple Tapes}, for information on
  8042. creating multiple volume archives.
  8043. @cindex Volume label, listing
  8044. @cindex Listing volume label
  8045. The volume label will be displayed by @option{--list} along with
  8046. the file contents. If verbose display is requested, it will also be
  8047. explicitely marked as in the example below:
  8048. @smallexample
  8049. @group
  8050. $ @kbd{tar --verbose --list --file=iamanarchive}
  8051. V--------- 0 0 0 1992-03-07 12:01 iamalabel--Volume Header--
  8052. -rw-r--r-- ringo user 40 1990-05-21 13:30 iamafilename
  8053. @end group
  8054. @end smallexample
  8055. @opindex test-label
  8056. @anchor{--test-label option}
  8057. However, @option{--list} option will cause listing entire
  8058. contents of the archive, which may be undesirable (for example, if the
  8059. archive is stored on a tape). You can request checking only the volume
  8060. by specifying @option{--test-label} option. This option reads only the
  8061. first block of an archive, so it can be used with slow storage
  8062. devices. For example:
  8063. @smallexample
  8064. @group
  8065. $ @kbd{tar --test-label --file=iamanarchive}
  8066. iamalabel
  8067. @end group
  8068. @end smallexample
  8069. If @option{--test-label} is used with a single command line
  8070. argument, @command{tar} compares the volume label with the
  8071. argument. It exits with code 0 if the two strings match, and with code
  8072. 2 otherwise. In this case no output is displayed. For example:
  8073. @smallexample
  8074. @group
  8075. $ @kbd{tar --test-label --file=iamanarchive 'iamalable'}
  8076. @result{} 0
  8077. $ @kbd{tar --test-label --file=iamanarchive 'iamalable' alabel}
  8078. @result{} 1
  8079. @end group
  8080. @end smallexample
  8081. If you request any operation, other than @option{--create}, along
  8082. with using @option{--label} option, @command{tar} will first check if
  8083. the archive label matches the one specified and will refuse to proceed
  8084. if it does not. Use this as a safety precaution to avoid accidentally
  8085. overwriting existing archives. For example, if you wish to add files
  8086. to @file{archive}, presumably labelled with string @samp{My volume},
  8087. you will get:
  8088. @smallexample
  8089. @group
  8090. $ @kbd{tar -rf archive --label 'My volume' .}
  8091. tar: Archive not labeled to match `My volume'
  8092. @end group
  8093. @end smallexample
  8094. @noindent
  8095. in case its label does not match. This will work even if
  8096. @file{archive} is not labelled at all.
  8097. Similarly, @command{tar} will refuse to list or extract the
  8098. archive if its label doesn't match the @var{archive-label}
  8099. specified. In those cases, @var{archive-label} argument is interpreted
  8100. as a globbing-style pattern which must match the actual magnetic
  8101. volume label. @xref{exclude}, for a precise description of how match
  8102. is attempted@footnote{Previous versions of @command{tar} used full
  8103. regular expression matching, or before that, only exact string
  8104. matching, instead of wildcard matchers. We decided for the sake of
  8105. simplicity to use a uniform matching device through
  8106. @command{tar}.}. If the switch @option{--multi-volume} (@option{-M}) is being used,
  8107. the volume label matcher will also suffix @var{archive-label} by
  8108. @w{@samp{ Volume [1-9]*}} if the initial match fails, before giving
  8109. up. Since the volume numbering is automatically added in labels at
  8110. creation time, it sounded logical to equally help the user taking care
  8111. of it when the archive is being read.
  8112. The @option{--label} was once called @option{--volume}, but is not
  8113. available under that name anymore.
  8114. You can also use @option{--label} to get a common information on
  8115. all tapes of a series. For having this information different in each
  8116. series created through a single script used on a regular basis, just
  8117. manage to get some date string as part of the label. For example:
  8118. @smallexample
  8119. @group
  8120. $ @kbd{tar cfMV /dev/tape "Daily backup for `date +%Y-%m-%d`"}
  8121. $ @kbd{tar --create --file=/dev/tape --multi-volume \
  8122. --volume="Daily backup for `date +%Y-%m-%d`"}
  8123. @end group
  8124. @end smallexample
  8125. Also note that each label has its own date and time, which corresponds
  8126. to when @GNUTAR{} initially attempted to write it,
  8127. often soon after the operator launches @command{tar} or types the
  8128. carriage return telling that the next tape is ready. Comparing date
  8129. labels does give an idea of tape throughput only if the delays for
  8130. rewinding tapes and the operator switching them were negligible, which
  8131. is usually not the case.
  8132. @node verify
  8133. @section Verifying Data as It is Stored
  8134. @cindex Verifying a write operation
  8135. @cindex Double-checking a write operation
  8136. @table @option
  8137. @item -W
  8138. @itemx --verify
  8139. @opindex verify, short description
  8140. Attempt to verify the archive after writing.
  8141. @end table
  8142. This option causes @command{tar} to verify the archive after writing it.
  8143. Each volume is checked after it is written, and any discrepancies
  8144. are recorded on the standard error output.
  8145. Verification requires that the archive be on a back-space-able medium.
  8146. This means pipes, some cartridge tape drives, and some other devices
  8147. cannot be verified.
  8148. You can insure the accuracy of an archive by comparing files in the
  8149. system with archive members. @command{tar} can compare an archive to the
  8150. file system as the archive is being written, to verify a write
  8151. operation, or can compare a previously written archive, to insure that
  8152. it is up to date.
  8153. @opindex verify, using with @option{--create}
  8154. @opindex create, using with @option{--verify}
  8155. To check for discrepancies in an archive immediately after it is
  8156. written, use the @option{--verify} (@option{-W}) option in conjunction with
  8157. the @option{--create} operation. When this option is
  8158. specified, @command{tar} checks archive members against their counterparts
  8159. in the file system, and reports discrepancies on the standard error.
  8160. To verify an archive, you must be able to read it from before the end
  8161. of the last written entry. This option is useful for detecting data
  8162. errors on some tapes. Archives written to pipes, some cartridge tape
  8163. drives, and some other devices cannot be verified.
  8164. One can explicitly compare an already made archive with the file
  8165. system by using the @option{--compare} (@option{--diff}, @option{-d})
  8166. option, instead of using the more automatic @option{--verify} option.
  8167. @xref{compare}.
  8168. Note that these two options have a slightly different intent. The
  8169. @option{--compare} option checks how identical are the logical contents of some
  8170. archive with what is on your disks, while the @option{--verify} option is
  8171. really for checking if the physical contents agree and if the recording
  8172. media itself is of dependable quality. So, for the @option{--verify}
  8173. operation, @command{tar} tries to defeat all in-memory cache pertaining to
  8174. the archive, while it lets the speed optimization undisturbed for the
  8175. @option{--compare} option. If you nevertheless use @option{--compare} for
  8176. media verification, you may have to defeat the in-memory cache yourself,
  8177. maybe by opening and reclosing the door latch of your recording unit,
  8178. forcing some doubt in your operating system about the fact this is really
  8179. the same volume as the one just written or read.
  8180. The @option{--verify} option would not be necessary if drivers were indeed
  8181. able to detect dependably all write failures. This sometimes require many
  8182. magnetic heads, some able to read after the writes occurred. One would
  8183. not say that drivers unable to detect all cases are necessarily flawed,
  8184. as long as programming is concerned.
  8185. The @option{--verify} (@option{-W}) option will not work in
  8186. conjunction with the @option{--multi-volume} (@option{-M}) option or
  8187. the @option{--append} (@option{-r}), @option{--update} (@option{-u})
  8188. and @option{--delete} operations. @xref{Operations}, for more
  8189. information on these operations.
  8190. Also, since @command{tar} normally strips leading @samp{/} from file
  8191. names (@pxref{absolute}), a command like @samp{tar --verify -cf
  8192. /tmp/foo.tar /etc} will work as desired only if the working directory is
  8193. @file{/}, as @command{tar} uses the archive's relative member names
  8194. (e.g., @file{etc/motd}) when verifying the archive.
  8195. @node Write Protection
  8196. @section Write Protection
  8197. Almost all tapes and diskettes, and in a few rare cases, even disks can
  8198. be @dfn{write protected}, to protect data on them from being changed.
  8199. Once an archive is written, you should write protect the media to prevent
  8200. the archive from being accidentally overwritten or deleted. (This will
  8201. protect the archive from being changed with a tape or floppy drive---it
  8202. will not protect it from magnet fields or other physical hazards).
  8203. The write protection device itself is usually an integral part of the
  8204. physical media, and can be a two position (write enabled/write
  8205. disabled) switch, a notch which can be popped out or covered, a ring
  8206. which can be removed from the center of a tape reel, or some other
  8207. changeable feature.
  8208. @node Changes
  8209. @appendix Changes
  8210. This appendix lists some important user-visible changes between
  8211. version @GNUTAR{} @value{VERSION} and previous versions. An up-to-date
  8212. version of this document is available at
  8213. @uref{http://www.gnu.org/@/software/@/tar/manual/changes.html,the
  8214. @GNUTAR{} documentation page}.
  8215. @table @asis
  8216. @item Use of globbing patterns when listing and extracting.
  8217. Previous versions of GNU tar assumed shell-style globbing when
  8218. extracting from or listing an archive. For example:
  8219. @smallexample
  8220. $ @kbd{tar xf foo.tar '*.c'}
  8221. @end smallexample
  8222. would extract all files whose names end in @samp{.c}. This behavior
  8223. was not documented and was incompatible with traditional tar
  8224. implementations. Therefore, starting from version 1.15.91, GNU tar
  8225. no longer uses globbing by default. For example, the above invocation
  8226. is now interpreted as a request to extract from the archive the file
  8227. named @file{*.c}.
  8228. To facilitate transition to the new behavior for those users who got
  8229. used to the previous incorrect one, @command{tar} will print a warning
  8230. if it finds out that a requested member was not found in the archive
  8231. and its name looks like a globbing pattern. For example:
  8232. @smallexample
  8233. $ @kbd{tar xf foo.tar '*.c'}
  8234. tar: Pattern matching characters used in file names. Please,
  8235. tar: use --wildcards to enable pattern matching, or --no-wildcards to
  8236. tar: suppress this warning.
  8237. tar: *.c: Not found in archive
  8238. tar: Error exit delayed from previous errors
  8239. @end smallexample
  8240. To treat member names as globbing patterns, use --wildcards option.
  8241. If you want to tar to mimic the behavior of versions prior to 1.15.91,
  8242. add this option to your @env{TAR_OPTIONS} variable.
  8243. @xref{wildcards}, for the detailed discussion of the use of globbing
  8244. patterns by @GNUTAR{}.
  8245. @item Use of short option @option{-o}.
  8246. Earlier versions of @GNUTAR{} understood @option{-o} command line
  8247. option as a synonym for @option{--old-archive}.
  8248. @GNUTAR{} starting from version 1.13.90 understands this option as
  8249. a synonym for @option{--no-same-owner}. This is compatible with
  8250. UNIX98 @command{tar} implementations.
  8251. However, to facilitate transition, @option{-o} option retains its
  8252. old semantics when it is used with one of archive-creation commands.
  8253. Users are encouraged to use @option{--format=oldgnu} instead.
  8254. It is especially important, since versions of @acronym{GNU} Automake
  8255. up to and including 1.8.4 invoke tar with this option to produce
  8256. distribution tarballs. @xref{Formats,v7}, for the detailed discussion
  8257. of this issue and its implications.
  8258. @FIXME{Change the first argument to tar-formats when the new Automake is
  8259. out. The proposition to add @anchor{} to the appropriate place of its
  8260. docs was accepted by Automake people --Sergey 2006-05-25}.
  8261. @xref{Options, tar-v7, Changing Automake's Behavior,
  8262. automake, GNU Automake}, for a description on how to use various
  8263. archive formats with @command{automake}.
  8264. Future versions of @GNUTAR{} will understand @option{-o} only as a
  8265. synonym for @option{--no-same-owner}.
  8266. @item Use of short option @option{-l}
  8267. Earlier versions of @GNUTAR{} understood @option{-l} option as a
  8268. synonym for @option{--one-file-system}. Since such usage contradicted
  8269. to UNIX98 specification and harmed compatibility with other
  8270. implementation, it was declared deprecated in version 1.14. However,
  8271. to facilitate transition to its new semantics, it was supported by
  8272. versions 1.15 and 1.15.90. The present use of @option{-l} as a short
  8273. variant of @option{--check-links} was introduced in version 1.15.91.
  8274. @item Use of options @option{--portability} and @option{--old-archive}
  8275. These options are deprecated. Please use @option{--format=v7} instead.
  8276. @item Use of option @option{--posix}
  8277. This option is deprecated. Please use @option{--format=posix} instead.
  8278. @end table
  8279. @node Configuring Help Summary
  8280. @appendix Configuring Help Summary
  8281. Running @kbd{tar --help} displays the short @command{tar} option
  8282. summary (@pxref{help}). This summary is organised by @dfn{groups} of
  8283. semantically close options. The options within each group are printed
  8284. in the following order: a short option, eventually followed by a list
  8285. of corresponding long option names, followed by a short description of
  8286. the option. For example, here is an excerpt from the actual @kbd{tar
  8287. --help} output:
  8288. @verbatim
  8289. Main operation mode:
  8290. -A, --catenate, --concatenate append tar files to an archive
  8291. -c, --create create a new archive
  8292. -d, --diff, --compare find differences between archive and
  8293. file system
  8294. --delete delete from the archive
  8295. @end verbatim
  8296. @vrindex ARGP_HELP_FMT, environment variable
  8297. The exact visual representation of the help output is configurable via
  8298. @env{ARGP_HELP_FMT} environment variable. The value of this variable
  8299. is a comma-separated list of @dfn{format variable} assignments. There
  8300. are two kinds of format variables. An @dfn{offset variable} keeps the
  8301. offset of some part of help output text from the leftmost column on
  8302. the screen. A @dfn{boolean} variable is a flag that toggles some
  8303. output feature on or off. Depending on the type of the corresponding
  8304. variable, there are two kinds of assignments:
  8305. @table @asis
  8306. @item Offset assignment
  8307. The assignment to an offset variable has the following syntax:
  8308. @smallexample
  8309. @var{variable}=@var{value}
  8310. @end smallexample
  8311. @noindent
  8312. where @var{variable} is the variable name, and @var{value} is a
  8313. numeric value to be assigned to the variable.
  8314. @item Boolean assignment
  8315. To assign @code{true} value to a variable, simply put this variable name. To
  8316. assign @code{false} value, prefix the variable name with @samp{no-}. For
  8317. example:
  8318. @smallexample
  8319. @group
  8320. # Assign @code{true} value:
  8321. dup-args
  8322. # Assign @code{false} value:
  8323. no-dup-args
  8324. @end group
  8325. @end smallexample
  8326. @end table
  8327. Following variables are declared:
  8328. @deftypevr {Help Output} boolean dup-args
  8329. If true, arguments for an option are shown with both short and long
  8330. options, even when a given option has both forms, for example:
  8331. @smallexample
  8332. -f ARCHIVE, --file=ARCHIVE use archive file or device ARCHIVE
  8333. @end smallexample
  8334. If false, then if an option has both short and long forms, the
  8335. argument is only shown with the long one, for example:
  8336. @smallexample
  8337. -f, --file=ARCHIVE use archive file or device ARCHIVE
  8338. @end smallexample
  8339. @noindent
  8340. and a message indicating that the argument is applicable to both
  8341. forms is printed below the options. This message can be disabled
  8342. using @code{dup-args-note} (see below).
  8343. The default is false.
  8344. @end deftypevr
  8345. @deftypevr {Help Output} boolean dup-args-note
  8346. If this variable is true, which is the default, the following notice
  8347. is displayed at the end of the help output:
  8348. @quotation
  8349. Mandatory or optional arguments to long options are also mandatory or
  8350. optional for any corresponding short options.
  8351. @end quotation
  8352. Setting @code{no-dup-args-note} inhibits this message. Normally, only one of
  8353. variables @code{dup-args} or @code{dup-args-note} should be set.
  8354. @end deftypevr
  8355. @deftypevr {Help Output} offset short-opt-col
  8356. Column in which short options start. Default is 2.
  8357. @smallexample
  8358. @group
  8359. $ @kbd{tar --help|grep ARCHIVE}
  8360. -f, --file=ARCHIVE use archive file or device ARCHIVE
  8361. $ @kbd{ARGP_HELP_FMT=short-opt-col=6 tar --help|grep ARCHIVE}
  8362. -f, --file=ARCHIVE use archive file or device ARCHIVE
  8363. @end group
  8364. @end smallexample
  8365. @end deftypevr
  8366. @deftypevr {Help Output} offset long-opt-col
  8367. Column in which long options start. Default is 6. For example:
  8368. @smallexample
  8369. @group
  8370. $ @kbd{tar --help|grep ARCHIVE}
  8371. -f, --file=ARCHIVE use archive file or device ARCHIVE
  8372. $ @kbd{ARGP_HELP_FMT=long-opt-col=16 tar --help|grep ARCHIVE}
  8373. -f, --file=ARCHIVE use archive file or device ARCHIVE
  8374. @end group
  8375. @end smallexample
  8376. @end deftypevr
  8377. @deftypevr {Help Output} offset doc-opt-col
  8378. Column in which @dfn{doc options} start. A doc option isn't actually
  8379. an option, but rather an arbitrary piece of documentation that is
  8380. displayed in much the same manner as the options. For example, in
  8381. the description of @option{--format} option:
  8382. @smallexample
  8383. @group
  8384. -H, --format=FORMAT create archive of the given format.
  8385. FORMAT is one of the following:
  8386. gnu GNU tar 1.13.x format
  8387. oldgnu GNU format as per tar <= 1.12
  8388. pax POSIX 1003.1-2001 (pax) format
  8389. posix same as pax
  8390. ustar POSIX 1003.1-1988 (ustar) format
  8391. v7 old V7 tar format
  8392. @end group
  8393. @end smallexample
  8394. @noindent
  8395. the format names are doc options. Thus, if you set
  8396. @kbd{ARGP_HELP_FMT=doc-opt-col=6} the above part of the help output
  8397. will look as follows:
  8398. @smallexample
  8399. @group
  8400. -H, --format=FORMAT create archive of the given format.
  8401. FORMAT is one of the following:
  8402. gnu GNU tar 1.13.x format
  8403. oldgnu GNU format as per tar <= 1.12
  8404. pax POSIX 1003.1-2001 (pax) format
  8405. posix same as pax
  8406. ustar POSIX 1003.1-1988 (ustar) format
  8407. v7 old V7 tar format
  8408. @end group
  8409. @end smallexample
  8410. @end deftypevr
  8411. @deftypevr {Help Output} offset opt-doc-col
  8412. Column in which option description starts. Default is 29.
  8413. @smallexample
  8414. @group
  8415. $ @kbd{tar --help|grep ARCHIVE}
  8416. -f, --file=ARCHIVE use archive file or device ARCHIVE
  8417. $ @kbd{ARGP_HELP_FMT=opt-doc-col=19 tar --help|grep ARCHIVE}
  8418. -f, --file=ARCHIVE use archive file or device ARCHIVE
  8419. $ @kbd{ARGP_HELP_FMT=opt-doc-col=9 tar --help|grep ARCHIVE}
  8420. -f, --file=ARCHIVE
  8421. use archive file or device ARCHIVE
  8422. @end group
  8423. @end smallexample
  8424. @noindent
  8425. Notice, that the description starts on a separate line if
  8426. @code{opt-doc-col} value is too small.
  8427. @end deftypevr
  8428. @deftypevr {Help Output} offset header-col
  8429. Column in which @dfn{group headers} are printed. A group header is a
  8430. descriptive text preceding an option group. For example, in the
  8431. following text:
  8432. @verbatim
  8433. Main operation mode:
  8434. -A, --catenate, --concatenate append tar files to
  8435. an archive
  8436. -c, --create create a new archive
  8437. @end verbatim
  8438. @noindent
  8439. @samp{Main operation mode:} is the group header.
  8440. The default value is 1.
  8441. @end deftypevr
  8442. @deftypevr {Help Output} offset usage-indent
  8443. Indentation of wrapped usage lines. Affects @option{--usage}
  8444. output. Default is 12.
  8445. @end deftypevr
  8446. @deftypevr {Help Output} offset rmargin
  8447. Right margin of the text output. Used for wrapping.
  8448. @end deftypevr
  8449. @node Genfile
  8450. @appendix Genfile
  8451. @include genfile.texi
  8452. @node Snapshot Files
  8453. @appendix Format of the Incremental Snapshot Files
  8454. @include snapshot.texi
  8455. @node Dumpdir
  8456. @appendix Dumpdir
  8457. @include dumpdir.texi
  8458. @node Free Software Needs Free Documentation
  8459. @appendix Free Software Needs Free Documentation
  8460. @include freemanuals.texi
  8461. @node Copying This Manual
  8462. @appendix Copying This Manual
  8463. @menu
  8464. * GNU Free Documentation License:: License for copying this manual
  8465. @end menu
  8466. @include fdl.texi
  8467. @node Index of Command Line Options
  8468. @appendix Index of Command Line Options
  8469. This appendix contains an index of all @GNUTAR{} long command line
  8470. options. The options are listed without the preceeding double-dash.
  8471. @FIXME{@itemize
  8472. @item Make sure @emph{all} options are indexed.
  8473. @item Provide an index of short options
  8474. @end itemize}
  8475. @printindex op
  8476. @node Index
  8477. @appendix Index
  8478. @printindex cp
  8479. @summarycontents
  8480. @contents
  8481. @bye
  8482. @c Local variables:
  8483. @c texinfo-column-for-description: 32
  8484. @c End: