tar.texi 405 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969
  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. @c Maintenance notes:
  11. @c 1. Pay attention to @FIXME{}s and @UNREVISED{}s
  12. @c 2. Before creating final variant:
  13. @c 2.1. Run `make check-options' to make sure all options are properly
  14. @c documented;
  15. @c 2.2. Run `make master-menu' (see comment before the master menu).
  16. @include rendition.texi
  17. @include value.texi
  18. @defcodeindex op
  19. @c Put everything in one index (arbitrarily chosen to be the concept index).
  20. @syncodeindex fn cp
  21. @syncodeindex ky cp
  22. @syncodeindex pg cp
  23. @syncodeindex vr cp
  24. @copying
  25. This manual is for @acronym{GNU} @command{tar} (version
  26. @value{VERSION}, @value{UPDATED}), which creates and extracts files
  27. from archives.
  28. Copyright @copyright{} 1992, 1994, 1995, 1996, 1997, 1999, 2000, 2001,
  29. 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
  30. @quotation
  31. Permission is granted to copy, distribute and/or modify this document
  32. under the terms of the GNU Free Documentation License, Version 1.1 or
  33. any later version published by the Free Software Foundation; with no
  34. Invariant Sections, with the Front-Cover Texts being ``A GNU Manual,''
  35. and with the Back-Cover Texts as in (a) below. A copy of the license
  36. is included in the section entitled "GNU Free Documentation License".
  37. (a) The FSF's Back-Cover Text is: ``You are free to copy and modify
  38. this GNU Manual. Buying copies from GNU Press supports the FSF in
  39. developing GNU and promoting software freedom.''
  40. @end quotation
  41. @end copying
  42. @dircategory Archiving
  43. @direntry
  44. * Tar: (tar). Making tape (or disk) archives.
  45. @end direntry
  46. @dircategory Individual utilities
  47. @direntry
  48. * tar: (tar)tar invocation. Invoking @GNUTAR{}.
  49. @end direntry
  50. @shorttitlepage @acronym{GNU} @command{tar}
  51. @titlepage
  52. @title @acronym{GNU} tar: an archiver tool
  53. @subtitle @value{RENDITION} @value{VERSION}, @value{UPDATED}
  54. @author John Gilmore, Jay Fenlason et al.
  55. @page
  56. @vskip 0pt plus 1filll
  57. @insertcopying
  58. @end titlepage
  59. @ifnottex
  60. @node Top
  61. @top @acronym{GNU} tar: an archiver tool
  62. @insertcopying
  63. @cindex file archival
  64. @cindex archiving files
  65. The first part of this master menu lists the major nodes in this Info
  66. document. The rest of the menu lists all the lower level nodes.
  67. @end ifnottex
  68. @c The master menu goes here.
  69. @c
  70. @c NOTE: To update it from within Emacs, make sure mastermenu.el is
  71. @c loaded and run texinfo-master-menu.
  72. @c To update it from the command line, run
  73. @c
  74. @c make master-menu
  75. @menu
  76. * Introduction::
  77. * Tutorial::
  78. * tar invocation::
  79. * operations::
  80. * Backups::
  81. * Choosing::
  82. * Date input formats::
  83. * Formats::
  84. * Media::
  85. Appendices
  86. * Changes::
  87. * Configuring Help Summary::
  88. * Fixing Snapshot Files::
  89. * Tar Internals::
  90. * Genfile::
  91. * Free Software Needs Free Documentation::
  92. * Copying This Manual::
  93. * Index of Command Line Options::
  94. * Index::
  95. @detailmenu
  96. --- The Detailed Node Listing ---
  97. Introduction
  98. * Book Contents:: What this Book Contains
  99. * Definitions:: Some Definitions
  100. * What tar Does:: What @command{tar} Does
  101. * Naming tar Archives:: How @command{tar} Archives are Named
  102. * Authors:: @GNUTAR{} Authors
  103. * Reports:: Reporting bugs or suggestions
  104. Tutorial Introduction to @command{tar}
  105. * assumptions::
  106. * stylistic conventions::
  107. * basic tar options:: Basic @command{tar} Operations and Options
  108. * frequent operations::
  109. * Two Frequent Options::
  110. * create:: How to Create Archives
  111. * list:: How to List Archives
  112. * extract:: How to Extract Members from an Archive
  113. * going further::
  114. Two Frequently Used Options
  115. * file tutorial::
  116. * verbose tutorial::
  117. * help tutorial::
  118. How to Create Archives
  119. * prepare for examples::
  120. * Creating the archive::
  121. * create verbose::
  122. * short create::
  123. * create dir::
  124. How to List Archives
  125. * list dir::
  126. How to Extract Members from an Archive
  127. * extracting archives::
  128. * extracting files::
  129. * extract dir::
  130. * extracting untrusted archives::
  131. * failing commands::
  132. Invoking @GNUTAR{}
  133. * Synopsis::
  134. * using tar options::
  135. * Styles::
  136. * All Options::
  137. * help::
  138. * defaults::
  139. * verbose::
  140. * interactive::
  141. The Three Option Styles
  142. * Long Options:: Long Option Style
  143. * Short Options:: Short Option Style
  144. * Old Options:: Old Option Style
  145. * Mixing:: Mixing Option Styles
  146. All @command{tar} Options
  147. * Operation Summary::
  148. * Option Summary::
  149. * Short Option Summary::
  150. @GNUTAR{} Operations
  151. * Basic tar::
  152. * Advanced tar::
  153. * create options::
  154. * extract options::
  155. * backup::
  156. * Applications::
  157. * looking ahead::
  158. Advanced @GNUTAR{} Operations
  159. * Operations::
  160. * append::
  161. * update::
  162. * concatenate::
  163. * delete::
  164. * compare::
  165. How to Add Files to Existing Archives: @option{--append}
  166. * appending files:: Appending Files to an Archive
  167. * multiple::
  168. Updating an Archive
  169. * how to update::
  170. Options Used by @option{--create}
  171. * override:: Overriding File Metadata.
  172. * Ignore Failed Read::
  173. Options Used by @option{--extract}
  174. * Reading:: Options to Help Read Archives
  175. * Writing:: Changing How @command{tar} Writes Files
  176. * Scarce:: Coping with Scarce Resources
  177. Options to Help Read Archives
  178. * read full records::
  179. * Ignore Zeros::
  180. Changing How @command{tar} Writes Files
  181. * Dealing with Old Files::
  182. * Overwrite Old Files::
  183. * Keep Old Files::
  184. * Keep Newer Files::
  185. * Unlink First::
  186. * Recursive Unlink::
  187. * Data Modification Times::
  188. * Setting Access Permissions::
  189. * Directory Modification Times and Permissions::
  190. * Writing to Standard Output::
  191. * Writing to an External Program::
  192. * remove files::
  193. Coping with Scarce Resources
  194. * Starting File::
  195. * Same Order::
  196. Performing Backups and Restoring Files
  197. * Full Dumps:: Using @command{tar} to Perform Full Dumps
  198. * Incremental Dumps:: Using @command{tar} to Perform Incremental Dumps
  199. * Backup Levels:: Levels of Backups
  200. * Backup Parameters:: Setting Parameters for Backups and Restoration
  201. * Scripted Backups:: Using the Backup Scripts
  202. * Scripted Restoration:: Using the Restore Script
  203. Setting Parameters for Backups and Restoration
  204. * General-Purpose Variables::
  205. * Magnetic Tape Control::
  206. * User Hooks::
  207. * backup-specs example:: An Example Text of @file{Backup-specs}
  208. Choosing Files and Names for @command{tar}
  209. * file:: Choosing the Archive's Name
  210. * Selecting Archive Members::
  211. * files:: Reading Names from a File
  212. * exclude:: Excluding Some Files
  213. * wildcards:: Wildcards Patterns and Matching
  214. * quoting styles:: Ways of Quoting Special Characters in Names
  215. * transform:: Modifying File and Member Names
  216. * after:: Operating Only on New Files
  217. * recurse:: Descending into Directories
  218. * one:: Crossing File System Boundaries
  219. Reading Names from a File
  220. * nul::
  221. Excluding Some Files
  222. * problems with exclude::
  223. Wildcards Patterns and Matching
  224. * controlling pattern-matching::
  225. Crossing File System Boundaries
  226. * directory:: Changing Directory
  227. * absolute:: Absolute File Names
  228. Date input formats
  229. * General date syntax:: Common rules.
  230. * Calendar date items:: 19 Dec 1994.
  231. * Time of day items:: 9:20pm.
  232. * Time zone items:: @sc{est}, @sc{pdt}, @sc{gmt}.
  233. * Day of week items:: Monday and others.
  234. * Relative items in date strings:: next tuesday, 2 years ago.
  235. * Pure numbers in date strings:: 19931219, 1440.
  236. * Seconds since the Epoch:: @@1078100502.
  237. * Specifying time zone rules:: TZ="America/New_York", TZ="UTC0".
  238. * Authors of get_date:: Bellovin, Eggert, Salz, Berets, et al.
  239. Controlling the Archive Format
  240. * Compression:: Using Less Space through Compression
  241. * Attributes:: Handling File Attributes
  242. * Portability:: Making @command{tar} Archives More Portable
  243. * cpio:: Comparison of @command{tar} and @command{cpio}
  244. Using Less Space through Compression
  245. * gzip:: Creating and Reading Compressed Archives
  246. * sparse:: Archiving Sparse Files
  247. Making @command{tar} Archives More Portable
  248. * Portable Names:: Portable Names
  249. * dereference:: Symbolic Links
  250. * old:: Old V7 Archives
  251. * ustar:: Ustar Archives
  252. * gnu:: GNU and old GNU format archives.
  253. * posix:: @acronym{POSIX} archives
  254. * Checksumming:: Checksumming Problems
  255. * Large or Negative Values:: Large files, negative time stamps, etc.
  256. * Other Tars:: How to Extract GNU-Specific Data Using
  257. Other @command{tar} Implementations
  258. @GNUTAR{} and @acronym{POSIX} @command{tar}
  259. * PAX keywords:: Controlling Extended Header Keywords.
  260. How to Extract GNU-Specific Data Using Other @command{tar} Implementations
  261. * Split Recovery:: Members Split Between Volumes
  262. * Sparse Recovery:: Sparse Members
  263. Tapes and Other Archive Media
  264. * Device:: Device selection and switching
  265. * Remote Tape Server::
  266. * Common Problems and Solutions::
  267. * Blocking:: Blocking
  268. * Many:: Many archives on one tape
  269. * Using Multiple Tapes:: Using Multiple Tapes
  270. * label:: Including a Label in the Archive
  271. * verify::
  272. * Write Protection::
  273. Blocking
  274. * Format Variations:: Format Variations
  275. * Blocking Factor:: The Blocking Factor of an Archive
  276. Many Archives on One Tape
  277. * Tape Positioning:: Tape Positions and Tape Marks
  278. * mt:: The @command{mt} Utility
  279. Using Multiple Tapes
  280. * Multi-Volume Archives:: Archives Longer than One Tape or Disk
  281. * Tape Files:: Tape Files
  282. * Tarcat:: Concatenate Volumes into a Single Archive
  283. Tar Internals
  284. * Standard:: Basic Tar Format
  285. * Extensions:: @acronym{GNU} Extensions to the Archive Format
  286. * Sparse Formats:: Storing Sparse Files
  287. * Snapshot Files::
  288. * Dumpdir::
  289. Storing Sparse Files
  290. * Old GNU Format::
  291. * PAX 0:: PAX Format, Versions 0.0 and 0.1
  292. * PAX 1:: PAX Format, Version 1.0
  293. Genfile
  294. * Generate Mode:: File Generation Mode.
  295. * Status Mode:: File Status Mode.
  296. * Exec Mode:: Synchronous Execution mode.
  297. Copying This Manual
  298. * GNU Free Documentation License:: License for copying this manual
  299. @end detailmenu
  300. @end menu
  301. @node Introduction
  302. @chapter Introduction
  303. @GNUTAR{} creates
  304. and manipulates @dfn{archives} which are actually collections of
  305. many other files; the program provides users with an organized and
  306. systematic method for controlling a large amount of data.
  307. The name ``tar'' originally came from the phrase ``Tape ARchive'', but
  308. archives need not (and these days, typically do not) reside on tapes.
  309. @menu
  310. * Book Contents:: What this Book Contains
  311. * Definitions:: Some Definitions
  312. * What tar Does:: What @command{tar} Does
  313. * Naming tar Archives:: How @command{tar} Archives are Named
  314. * Authors:: @GNUTAR{} Authors
  315. * Reports:: Reporting bugs or suggestions
  316. @end menu
  317. @node Book Contents
  318. @section What this Book Contains
  319. The first part of this chapter introduces you to various terms that will
  320. recur throughout the book. It also tells you who has worked on @GNUTAR{}
  321. and its documentation, and where you should send bug reports
  322. or comments.
  323. The second chapter is a tutorial (@pxref{Tutorial}) which provides a
  324. gentle introduction for people who are new to using @command{tar}. It is
  325. meant to be self contained, not requiring any reading from subsequent
  326. chapters to make sense. It moves from topic to topic in a logical,
  327. progressive order, building on information already explained.
  328. Although the tutorial is paced and structured to allow beginners to
  329. learn how to use @command{tar}, it is not intended solely for beginners.
  330. The tutorial explains how to use the three most frequently used
  331. operations (@samp{create}, @samp{list}, and @samp{extract}) as well as
  332. two frequently used options (@samp{file} and @samp{verbose}). The other
  333. chapters do not refer to the tutorial frequently; however, if a section
  334. discusses something which is a complex variant of a basic concept, there
  335. may be a cross reference to that basic concept. (The entire book,
  336. including the tutorial, assumes that the reader understands some basic
  337. concepts of using a Unix-type operating system; @pxref{Tutorial}.)
  338. The third chapter presents the remaining five operations, and
  339. information about using @command{tar} options and option syntax.
  340. @FIXME{this sounds more like a @acronym{GNU} Project Manuals Concept [tm] more
  341. than the reality. should think about whether this makes sense to say
  342. here, or not.} The other chapters are meant to be used as a
  343. reference. Each chapter presents everything that needs to be said
  344. about a specific topic.
  345. One of the chapters (@pxref{Date input formats}) exists in its
  346. entirety in other @acronym{GNU} manuals, and is mostly self-contained.
  347. In addition, one section of this manual (@pxref{Standard}) contains a
  348. big quote which is taken directly from @command{tar} sources.
  349. In general, we give both long and short (abbreviated) option names
  350. at least once in each section where the relevant option is covered, so
  351. that novice readers will become familiar with both styles. (A few
  352. options have no short versions, and the relevant sections will
  353. indicate this.)
  354. @node Definitions
  355. @section Some Definitions
  356. @cindex archive
  357. @cindex tar archive
  358. The @command{tar} program is used to create and manipulate @command{tar}
  359. archives. An @dfn{archive} is a single file which contains the contents
  360. of many files, while still identifying the names of the files, their
  361. owner(s), and so forth. (In addition, archives record access
  362. permissions, user and group, size in bytes, and data modification time.
  363. Some archives also record the file names in each archived directory, as
  364. well as other file and directory information.) You can use @command{tar}
  365. to @dfn{create} a new archive in a specified directory.
  366. @cindex member
  367. @cindex archive member
  368. @cindex file name
  369. @cindex member name
  370. The files inside an archive are called @dfn{members}. Within this
  371. manual, we use the term @dfn{file} to refer only to files accessible in
  372. the normal ways (by @command{ls}, @command{cat}, and so forth), and the term
  373. @dfn{member} to refer only to the members of an archive. Similarly, a
  374. @dfn{file name} is the name of a file, as it resides in the file system,
  375. and a @dfn{member name} is the name of an archive member within the
  376. archive.
  377. @cindex extraction
  378. @cindex unpacking
  379. The term @dfn{extraction} refers to the process of copying an archive
  380. member (or multiple members) into a file in the file system. Extracting
  381. all the members of an archive is often called @dfn{extracting the
  382. archive}. The term @dfn{unpack} can also be used to refer to the
  383. extraction of many or all the members of an archive. Extracting an
  384. archive does not destroy the archive's structure, just as creating an
  385. archive does not destroy the copies of the files that exist outside of
  386. the archive. You may also @dfn{list} the members in a given archive
  387. (this is often thought of as ``printing'' them to the standard output,
  388. or the command line), or @dfn{append} members to a pre-existing archive.
  389. All of these operations can be performed using @command{tar}.
  390. @node What tar Does
  391. @section What @command{tar} Does
  392. @cindex tar
  393. The @command{tar} program provides the ability to create @command{tar}
  394. archives, as well as various other kinds of manipulation. For example,
  395. you can use @command{tar} on previously created archives to extract files,
  396. to store additional files, or to update or list files which were already
  397. stored.
  398. Initially, @command{tar} archives were used to store files conveniently on
  399. magnetic tape. The name @command{tar} comes from this use; it stands for
  400. @code{t}ape @code{ar}chiver. Despite the utility's name, @command{tar} can
  401. direct its output to available devices, files, or other programs (using
  402. pipes). @command{tar} may even access remote devices or files (as archives).
  403. You can use @command{tar} archives in many ways. We want to stress a few
  404. of them: storage, backup, and transportation.
  405. @FIXME{the following table entries need a bit of work.}
  406. @table @asis
  407. @item Storage
  408. Often, @command{tar} archives are used to store related files for
  409. convenient file transfer over a network. For example, the
  410. @acronym{GNU} Project distributes its software bundled into
  411. @command{tar} archives, so that all the files relating to a particular
  412. program (or set of related programs) can be transferred as a single
  413. unit.
  414. A magnetic tape can store several files in sequence. However, the tape
  415. has no names for these files; it only knows their relative position on
  416. the tape. One way to store several files on one tape and retain their
  417. names is by creating a @command{tar} archive. Even when the basic transfer
  418. mechanism can keep track of names, as FTP can, the nuisance of handling
  419. multiple files, directories, and multiple links makes @command{tar}
  420. archives useful.
  421. Archive files are also used for long-term storage. You can think of
  422. this as transportation from the present into the future. (It is a
  423. science-fiction idiom that you can move through time as well as in
  424. space; the idea here is that @command{tar} can be used to move archives in
  425. all dimensions, even time!)
  426. @item Backup
  427. Because the archive created by @command{tar} is capable of preserving
  428. file information and directory structure, @command{tar} is commonly
  429. used for performing full and incremental backups of disks. A backup
  430. puts a collection of files (possibly pertaining to many users and
  431. projects) together on a disk or a tape. This guards against
  432. accidental destruction of the information in those files.
  433. @GNUTAR{} has special features that allow it to be
  434. used to make incremental and full dumps of all the files in a
  435. file system.
  436. @item Transportation
  437. You can create an archive on one system, transfer it to another system,
  438. and extract the contents there. This allows you to transport a group of
  439. files from one system to another.
  440. @end table
  441. @node Naming tar Archives
  442. @section How @command{tar} Archives are Named
  443. Conventionally, @command{tar} archives are given names ending with
  444. @samp{.tar}. This is not necessary for @command{tar} to operate properly,
  445. but this manual follows that convention in order to accustom readers to
  446. it and to make examples more clear.
  447. @cindex tar file
  448. @cindex entry
  449. @cindex tar entry
  450. Often, people refer to @command{tar} archives as ``@command{tar} files,'' and
  451. archive members as ``files'' or ``entries''. For people familiar with
  452. the operation of @command{tar}, this causes no difficulty. However, in
  453. this manual, we consistently refer to ``archives'' and ``archive
  454. members'' to make learning to use @command{tar} easier for novice users.
  455. @node Authors
  456. @section @GNUTAR{} Authors
  457. @GNUTAR{} was originally written by John Gilmore,
  458. and modified by many people. The @acronym{GNU} enhancements were
  459. written by Jay Fenlason, then Joy Kendall, and the whole package has
  460. been further maintained by Thomas Bushnell, n/BSG, Fran@,{c}ois
  461. Pinard, Paul Eggert, and finally Sergey Poznyakoff with the help of
  462. numerous and kind users.
  463. We wish to stress that @command{tar} is a collective work, and owes much to
  464. all those people who reported problems, offered solutions and other
  465. insights, or shared their thoughts and suggestions. An impressive, yet
  466. partial list of those contributors can be found in the @file{THANKS}
  467. file from the @GNUTAR{} distribution.
  468. @FIXME{i want all of these names mentioned, Absolutely. BUT, i'm not
  469. sure i want to spell out the history in this detail, at least not for
  470. the printed book. i'm just not sure it needs to be said this way.
  471. i'll think about it.}
  472. @FIXME{History is more important, and surely more interesting, than
  473. actual names. Quoting names without history would be meaningless. FP}
  474. Jay Fenlason put together a draft of a @GNUTAR{}
  475. manual, borrowing notes from the original man page from John Gilmore.
  476. This was withdrawn in version 1.11. Thomas Bushnell, n/BSG and Amy
  477. Gorin worked on a tutorial and manual for @GNUTAR{}.
  478. Fran@,{c}ois Pinard put version 1.11.8 of the manual together by
  479. taking information from all these sources and merging them. Melissa
  480. Weisshaus finally edited and redesigned the book to create version
  481. 1.12. The book for versions from 1.14 up to @value{VERSION} were edited
  482. by the current maintainer, Sergey Poznyakoff.
  483. For version 1.12, Daniel Hagerty contributed a great deal of technical
  484. consulting. In particular, he is the primary author of @ref{Backups}.
  485. In July, 2003 @GNUTAR{} was put on CVS at savannah.gnu.org
  486. (see @url{http://savannah.gnu.org/projects/tar}), and
  487. active development and maintenance work has started
  488. again. Currently @GNUTAR{} is being maintained by Paul Eggert, Sergey
  489. Poznyakoff and Jeff Bailey.
  490. Support for @acronym{POSIX} archives was added by Sergey Poznyakoff.
  491. @node Reports
  492. @section Reporting bugs or suggestions
  493. @cindex bug reports
  494. @cindex reporting bugs
  495. If you find problems or have suggestions about this program or manual,
  496. please report them to @file{bug-tar@@gnu.org}.
  497. When reporting a bug, please be sure to include as much detail as
  498. possible, in order to reproduce it. @FIXME{Be more specific, I'd
  499. like to make this node as detailed as 'Bug reporting' node in Emacs
  500. manual}.
  501. @node Tutorial
  502. @chapter Tutorial Introduction to @command{tar}
  503. This chapter guides you through some basic examples of three @command{tar}
  504. operations: @option{--create}, @option{--list}, and @option{--extract}. If
  505. you already know how to use some other version of @command{tar}, then you
  506. may not need to read this chapter. This chapter omits most complicated
  507. details about how @command{tar} works.
  508. @menu
  509. * assumptions::
  510. * stylistic conventions::
  511. * basic tar options:: Basic @command{tar} Operations and Options
  512. * frequent operations::
  513. * Two Frequent Options::
  514. * create:: How to Create Archives
  515. * list:: How to List Archives
  516. * extract:: How to Extract Members from an Archive
  517. * going further::
  518. @end menu
  519. @node assumptions
  520. @section Assumptions this Tutorial Makes
  521. This chapter is paced to allow beginners to learn about @command{tar}
  522. slowly. At the same time, we will try to cover all the basic aspects of
  523. these three operations. In order to accomplish both of these tasks, we
  524. have made certain assumptions about your knowledge before reading this
  525. manual, and the hardware you will be using:
  526. @itemize @bullet
  527. @item
  528. Before you start to work through this tutorial, you should understand
  529. what the terms ``archive'' and ``archive member'' mean
  530. (@pxref{Definitions}). In addition, you should understand something
  531. about how Unix-type operating systems work, and you should know how to
  532. use some basic utilities. For example, you should know how to create,
  533. list, copy, rename, edit, and delete files and directories; how to
  534. change between directories; and how to figure out where you are in the
  535. file system. You should have some basic understanding of directory
  536. structure and how files are named according to which directory they are
  537. in. You should understand concepts such as standard output and standard
  538. input, what various definitions of the term ``argument'' mean, and the
  539. differences between relative and absolute file names. @FIXME{and what
  540. else?}
  541. @item
  542. This manual assumes that you are working from your own home directory
  543. (unless we state otherwise). In this tutorial, you will create a
  544. directory to practice @command{tar} commands in. When we show file names,
  545. we will assume that those names are relative to your home directory.
  546. For example, my home directory is @file{/home/fsf/melissa}. All of
  547. my examples are in a subdirectory of the directory named by that file
  548. name; the subdirectory is called @file{practice}.
  549. @item
  550. In general, we show examples of archives which exist on (or can be
  551. written to, or worked with from) a directory on a hard disk. In most
  552. cases, you could write those archives to, or work with them on any other
  553. device, such as a tape drive. However, some of the later examples in
  554. the tutorial and next chapter will not work on tape drives.
  555. Additionally, working with tapes is much more complicated than working
  556. with hard disks. For these reasons, the tutorial does not cover working
  557. with tape drives. @xref{Media}, for complete information on using
  558. @command{tar} archives with tape drives.
  559. @FIXME{this is a cop out. need to add some simple tape drive info.}
  560. @end itemize
  561. @node stylistic conventions
  562. @section Stylistic Conventions
  563. In the examples, @samp{$} represents a typical shell prompt. It
  564. precedes lines you should type; to make this more clear, those lines are
  565. shown in @kbd{this font}, as opposed to lines which represent the
  566. computer's response; those lines are shown in @code{this font}, or
  567. sometimes @samp{like this}.
  568. @c When we have lines which are too long to be
  569. @c displayed in any other way, we will show them like this:
  570. @node basic tar options
  571. @section Basic @command{tar} Operations and Options
  572. @command{tar} can take a wide variety of arguments which specify and define
  573. the actions it will have on the particular set of files or the archive.
  574. The main types of arguments to @command{tar} fall into one of two classes:
  575. operations, and options.
  576. Some arguments fall into a class called @dfn{operations}; exactly one of
  577. these is both allowed and required for any instance of using @command{tar};
  578. you may @emph{not} specify more than one. People sometimes speak of
  579. @dfn{operating modes}. You are in a particular operating mode when you
  580. have specified the operation which specifies it; there are eight
  581. operations in total, and thus there are eight operating modes.
  582. The other arguments fall into the class known as @dfn{options}. You are
  583. not required to specify any options, and you are allowed to specify more
  584. than one at a time (depending on the way you are using @command{tar} at
  585. that time). Some options are used so frequently, and are so useful for
  586. helping you type commands more carefully that they are effectively
  587. ``required''. We will discuss them in this chapter.
  588. You can write most of the @command{tar} operations and options in any
  589. of three forms: long (mnemonic) form, short form, and old style. Some
  590. of the operations and options have no short or ``old'' forms; however,
  591. the operations and options which we will cover in this tutorial have
  592. corresponding abbreviations. @FIXME{make sure this is still the case,
  593. at the end}We will indicate those abbreviations appropriately to get
  594. you used to seeing them. (Note that the ``old style'' option forms
  595. exist in @GNUTAR{} for compatibility with Unix
  596. @command{tar}. In this book we present a full discussion of this way
  597. of writing options and operations (@pxref{Old Options}), and we discuss
  598. the other two styles of writing options (@xref{Long Options}, and
  599. @pxref{Short Options}).
  600. In the examples and in the text of this tutorial, we usually use the
  601. long forms of operations and options; but the ``short'' forms produce
  602. the same result and can make typing long @command{tar} commands easier.
  603. For example, instead of typing
  604. @smallexample
  605. @kbd{tar --create --verbose --file=afiles.tar apple angst aspic}
  606. @end smallexample
  607. @noindent
  608. you can type
  609. @smallexample
  610. @kbd{tar -c -v -f afiles.tar apple angst aspic}
  611. @end smallexample
  612. @noindent
  613. or even
  614. @smallexample
  615. @kbd{tar -cvf afiles.tar apple angst aspic}
  616. @end smallexample
  617. @noindent
  618. For more information on option syntax, see @ref{Advanced tar}. In
  619. discussions in the text, when we name an option by its long form, we
  620. also give the corresponding short option in parentheses.
  621. The term, ``option'', can be confusing at times, since ``operations''
  622. are often lumped in with the actual, @emph{optional} ``options'' in certain
  623. general class statements. For example, we just talked about ``short and
  624. long forms of options and operations''. However, experienced @command{tar}
  625. users often refer to these by shorthand terms such as, ``short and long
  626. options''. This term assumes that the ``operations'' are included, also.
  627. Context will help you determine which definition of ``options'' to use.
  628. Similarly, the term ``command'' can be confusing, as it is often used in
  629. two different ways. People sometimes refer to @command{tar} ``commands''.
  630. A @command{tar} @dfn{command} is the entire command line of user input
  631. which tells @command{tar} what to do --- including the operation, options,
  632. and any arguments (file names, pipes, other commands, etc.). However,
  633. you will also sometimes hear the term ``the @command{tar} command''. When
  634. the word ``command'' is used specifically like this, a person is usually
  635. referring to the @command{tar} @emph{operation}, not the whole line.
  636. Again, use context to figure out which of the meanings the speaker
  637. intends.
  638. @node frequent operations
  639. @section The Three Most Frequently Used Operations
  640. Here are the three most frequently used operations (both short and long
  641. forms), as well as a brief description of their meanings. The rest of
  642. this chapter will cover how to use these operations in detail. We will
  643. present the rest of the operations in the next chapter.
  644. @table @option
  645. @item --create
  646. @itemx -c
  647. Create a new @command{tar} archive.
  648. @item --list
  649. @itemx -t
  650. List the contents of an archive.
  651. @item --extract
  652. @itemx -x
  653. Extract one or more members from an archive.
  654. @end table
  655. @node Two Frequent Options
  656. @section Two Frequently Used Options
  657. To understand how to run @command{tar} in the three operating modes listed
  658. previously, you also need to understand how to use two of the options to
  659. @command{tar}: @option{--file} (which takes an archive file as an argument)
  660. and @option{--verbose}. (You are usually not @emph{required} to specify
  661. either of these options when you run @command{tar}, but they can be very
  662. useful in making things more clear and helping you avoid errors.)
  663. @menu
  664. * file tutorial::
  665. * verbose tutorial::
  666. * help tutorial::
  667. @end menu
  668. @node file tutorial
  669. @unnumberedsubsec The @option{--file} Option
  670. @table @option
  671. @xopindex{file, tutorial}
  672. @item --file=@var{archive-name}
  673. @itemx -f @var{archive-name}
  674. Specify the name of an archive file.
  675. @end table
  676. You can specify an argument for the @option{--file=@var{archive-name}} (@option{-f @var{archive-name}}) option whenever you
  677. use @command{tar}; this option determines the name of the archive file
  678. that @command{tar} will work on.
  679. @vrindex TAPE
  680. If you don't specify this argument, then @command{tar} will examine
  681. the environment variable @env{TAPE}. If it is set, its value will be
  682. used as the archive name. Otherwise, @command{tar} will use the
  683. default archive, determined at the compile time. Usually it is
  684. standard output or some physical tape drive attached to your machine
  685. (you can verify what the default is by running @kbd{tar
  686. --show-defaults}, @pxref{defaults}). If there is no tape drive
  687. attached, or the default is not meaningful, then @command{tar} will
  688. print an error message. The error message might look roughly like one
  689. of the following:
  690. @smallexample
  691. tar: can't open /dev/rmt8 : No such device or address
  692. tar: can't open /dev/rsmt0 : I/O error
  693. @end smallexample
  694. @noindent
  695. To avoid confusion, we recommend that you always specify an archive file
  696. name by using @option{--file=@var{archive-name}} (@option{-f @var{archive-name}}) when writing your @command{tar} commands.
  697. For more information on using the @option{--file=@var{archive-name}} (@option{-f @var{archive-name}}) option, see
  698. @ref{file}.
  699. @node verbose tutorial
  700. @unnumberedsubsec The @option{--verbose} Option
  701. @table @option
  702. @xopindex{verbose, introduced}
  703. @item --verbose
  704. @itemx -v
  705. Show the files being worked on as @command{tar} is running.
  706. @end table
  707. @option{--verbose} (@option{-v}) shows details about the results of running
  708. @command{tar}. This can be especially useful when the results might not be
  709. obvious. For example, if you want to see the progress of @command{tar} as
  710. it writes files into the archive, you can use the @option{--verbose}
  711. option. In the beginning, you may find it useful to use
  712. @option{--verbose} at all times; when you are more accustomed to
  713. @command{tar}, you will likely want to use it at certain times but not at
  714. others. We will use @option{--verbose} at times to help make something
  715. clear, and we will give many examples both using and not using
  716. @option{--verbose} to show the differences.
  717. Each instance of @option{--verbose} on the command line increases the
  718. verbosity level by one, so if you need more details on the output,
  719. specify it twice.
  720. When reading archives (@option{--list}, @option{--extract},
  721. @option{--diff}), @command{tar} by default prints only the names of
  722. the members being extracted. Using @option{--verbose} will show a full,
  723. @command{ls} style member listing.
  724. In contrast, when writing archives (@option{--create}, @option{--append},
  725. @option{--update}), @command{tar} does not print file names by
  726. default. So, a single @option{--verbose} option shows the file names
  727. being added to the archive, while two @option{--verbose} options
  728. enable the full listing.
  729. For example, to create an archive in verbose mode:
  730. @smallexample
  731. $ @kbd{tar -cvf afiles.tar apple angst aspic}
  732. apple
  733. angst
  734. aspic
  735. @end smallexample
  736. @noindent
  737. Creating the same archive with the verbosity level 2 could give:
  738. @smallexample
  739. $ @kbd{tar -cvvf afiles.tar apple angst aspic}
  740. -rw-r--r-- gray/staff 62373 2006-06-09 12:06 apple
  741. -rw-r--r-- gray/staff 11481 2006-06-09 12:06 angst
  742. -rw-r--r-- gray/staff 23152 2006-06-09 12:06 aspic
  743. @end smallexample
  744. @noindent
  745. This works equally well using short or long forms of options. Using
  746. long forms, you would simply write out the mnemonic form of the option
  747. twice, like this:
  748. @smallexample
  749. $ @kbd{tar --create --verbose --verbose @dots{}}
  750. @end smallexample
  751. @noindent
  752. Note that you must double the hyphens properly each time.
  753. Later in the tutorial, we will give examples using @w{@option{--verbose
  754. --verbose}}.
  755. @anchor{verbose member listing}
  756. The full output consists of six fields:
  757. @itemize @bullet
  758. @item File type and permissions in symbolic form.
  759. These are displayed in the same format as the first column of
  760. @command{ls -l} output (@pxref{What information is listed,
  761. format=verbose, Verbose listing, fileutils, GNU file utilities}).
  762. @item Owner name and group separated by a slash character.
  763. If these data are not available (for example, when listing a @samp{v7} format
  764. archive), numeric @acronym{ID} values are printed instead.
  765. @item Size of the file, in bytes.
  766. @item File modification date in ISO 8601 format.
  767. @item File modification time.
  768. @item File name.
  769. If the name contains any special characters (white space, newlines,
  770. etc.) these are displayed in an unambiguous form using so called
  771. @dfn{quoting style}. For the detailed discussion of available styles
  772. and on how to use them, see @ref{quoting styles}.
  773. Depending on the file type, the name can be followed by some
  774. additional information, described in the following table:
  775. @table @samp
  776. @item -> @var{link-name}
  777. The file or archive member is a @dfn{symbolic link} and
  778. @var{link-name} is the name of file it links to.
  779. @item link to @var{link-name}
  780. The file or archive member is a @dfn{hard link} and @var{link-name} is
  781. the name of file it links to.
  782. @item --Long Link--
  783. The archive member is an old GNU format long link. You will normally
  784. not encounter this.
  785. @item --Long Name--
  786. The archive member is an old GNU format long name. You will normally
  787. not encounter this.
  788. @item --Volume Header--
  789. The archive member is a GNU @dfn{volume header} (@pxref{Tape Files}).
  790. @item --Continued at byte @var{n}--
  791. Encountered only at the beginning of a multi-volume archive
  792. (@pxref{Using Multiple Tapes}). This archive member is a continuation
  793. from the previous volume. The number @var{n} gives the offset where
  794. the original file was split.
  795. @item unknown file type @var{c}
  796. An archive member of unknown type. @var{c} is the type character from
  797. the archive header. If you encounter such a message, it means that
  798. either your archive contains proprietary member types @GNUTAR{} is not
  799. able to handle, or the archive is corrupted.
  800. @end table
  801. @end itemize
  802. For example, here is an archive listing containing most of the special
  803. suffixes explained above:
  804. @smallexample
  805. @group
  806. V--------- 0/0 1536 2006-06-09 13:07 MyVolume--Volume Header--
  807. -rw-r--r-- gray/staff 456783 2006-06-09 12:06 aspic--Continued at
  808. byte 32456--
  809. -rw-r--r-- gray/staff 62373 2006-06-09 12:06 apple
  810. lrwxrwxrwx gray/staff 0 2006-06-09 13:01 angst -> apple
  811. -rw-r--r-- gray/staff 35793 2006-06-09 12:06 blues
  812. hrw-r--r-- gray/staff 0 2006-06-09 12:06 music link to blues
  813. @end group
  814. @end smallexample
  815. @smallexample
  816. @end smallexample
  817. @node help tutorial
  818. @unnumberedsubsec Getting Help: Using the @option{--help} Option
  819. @table @option
  820. @opindex help
  821. @item --help
  822. The @option{--help} option to @command{tar} prints out a very brief list of
  823. all operations and option available for the current version of
  824. @command{tar} available on your system.
  825. @end table
  826. @node create
  827. @section How to Create Archives
  828. @UNREVISED
  829. @cindex Creation of the archive
  830. @cindex Archive, creation of
  831. One of the basic operations of @command{tar} is @option{--create} (@option{-c}), which
  832. you use to create a @command{tar} archive. We will explain
  833. @option{--create} first because, in order to learn about the other
  834. operations, you will find it useful to have an archive available to
  835. practice on.
  836. To make this easier, in this section you will first create a directory
  837. containing three files. Then, we will show you how to create an
  838. @emph{archive} (inside the new directory). Both the directory, and
  839. the archive are specifically for you to practice on. The rest of this
  840. chapter and the next chapter will show many examples using this
  841. directory and the files you will create: some of those files may be
  842. other directories and other archives.
  843. The three files you will archive in this example are called
  844. @file{blues}, @file{folk}, and @file{jazz}. The archive is called
  845. @file{collection.tar}.
  846. This section will proceed slowly, detailing how to use @option{--create}
  847. in @code{verbose} mode, and showing examples using both short and long
  848. forms. In the rest of the tutorial, and in the examples in the next
  849. chapter, we will proceed at a slightly quicker pace. This section
  850. moves more slowly to allow beginning users to understand how
  851. @command{tar} works.
  852. @menu
  853. * prepare for examples::
  854. * Creating the archive::
  855. * create verbose::
  856. * short create::
  857. * create dir::
  858. @end menu
  859. @node prepare for examples
  860. @subsection Preparing a Practice Directory for Examples
  861. To follow along with this and future examples, create a new directory
  862. called @file{practice} containing files called @file{blues}, @file{folk}
  863. and @file{jazz}. The files can contain any information you like:
  864. ideally, they should contain information which relates to their names,
  865. and be of different lengths. Our examples assume that @file{practice}
  866. is a subdirectory of your home directory.
  867. Now @command{cd} to the directory named @file{practice}; @file{practice}
  868. is now your @dfn{working directory}. (@emph{Please note}: Although
  869. the full file name of this directory is
  870. @file{/@var{homedir}/practice}, in our examples we will refer to
  871. this directory as @file{practice}; the @var{homedir} is presumed.
  872. In general, you should check that the files to be archived exist where
  873. you think they do (in the working directory) by running @command{ls}.
  874. Because you just created the directory and the files and have changed to
  875. that directory, you probably don't need to do that this time.
  876. It is very important to make sure there isn't already a file in the
  877. working directory with the archive name you intend to use (in this case,
  878. @samp{collection.tar}), or that you don't care about its contents.
  879. Whenever you use @samp{create}, @command{tar} will erase the current
  880. contents of the file named by @option{--file=@var{archive-name}} (@option{-f @var{archive-name}}) if it exists. @command{tar}
  881. will not tell you if you are about to overwrite an archive unless you
  882. specify an option which does this (@pxref{backup}, for the
  883. information on how to do so). To add files to an existing archive,
  884. you need to use a different option, such as @option{--append} (@option{-r}); see
  885. @ref{append} for information on how to do this.
  886. @node Creating the archive
  887. @subsection Creating the Archive
  888. @xopindex{create, introduced}
  889. To place the files @file{blues}, @file{folk}, and @file{jazz} into an
  890. archive named @file{collection.tar}, use the following command:
  891. @smallexample
  892. $ @kbd{tar --create --file=collection.tar blues folk jazz}
  893. @end smallexample
  894. The order of the arguments is not very important, @emph{when using long
  895. option forms}. You could also say:
  896. @smallexample
  897. $ @kbd{tar blues --create folk --file=collection.tar jazz}
  898. @end smallexample
  899. @noindent
  900. However, you can see that this order is harder to understand; this is
  901. why we will list the arguments in the order that makes the commands
  902. easiest to understand (and we encourage you to do the same when you use
  903. @command{tar}, to avoid errors).
  904. Note that the sequence
  905. @option{[email protected]} is considered to be @emph{one} argument.
  906. If you substituted any other string of characters for
  907. @kbd{collection.tar}, then that string would become the name of the
  908. archive file you create.
  909. The order of the options becomes more important when you begin to use
  910. short forms. With short forms, if you type commands in the wrong order
  911. (even if you type them correctly in all other ways), you may end up with
  912. results you don't expect. For this reason, it is a good idea to get
  913. into the habit of typing options in the order that makes inherent sense.
  914. @xref{short create}, for more information on this.
  915. In this example, you type the command as shown above: @option{--create}
  916. is the operation which creates the new archive
  917. (@file{collection.tar}), and @option{--file} is the option which lets
  918. you give it the name you chose. The files, @file{blues}, @file{folk},
  919. and @file{jazz}, are now members of the archive, @file{collection.tar}
  920. (they are @dfn{file name arguments} to the @option{--create} operation.
  921. @xref{Choosing}, for the detailed discussion on these.) Now that they are
  922. in the archive, they are called @emph{archive members}, not files.
  923. (@pxref{Definitions,members}).
  924. When you create an archive, you @emph{must} specify which files you
  925. want placed in the archive. If you do not specify any archive
  926. members, @GNUTAR{} will complain.
  927. If you now list the contents of the working directory (@command{ls}), you will
  928. find the archive file listed as well as the files you saw previously:
  929. @smallexample
  930. blues folk jazz collection.tar
  931. @end smallexample
  932. @noindent
  933. Creating the archive @samp{collection.tar} did not destroy the copies of
  934. the files in the directory.
  935. Keep in mind that if you don't indicate an operation, @command{tar} will not
  936. run and will prompt you for one. If you don't name any files, @command{tar}
  937. will complain. You must have write access to the working directory,
  938. or else you will not be able to create an archive in that directory.
  939. @emph{Caution}: Do not attempt to use @option{--create} (@option{-c}) to add files to
  940. an existing archive; it will delete the archive and write a new one.
  941. Use @option{--append} (@option{-r}) instead. @xref{append}.
  942. @node create verbose
  943. @subsection Running @option{--create} with @option{--verbose}
  944. @xopindex{create, using with @option{--verbose}}
  945. @xopindex{verbose, using with @option{--create}}
  946. If you include the @option{--verbose} (@option{-v}) option on the command line,
  947. @command{tar} will list the files it is acting on as it is working. In
  948. verbose mode, the @code{create} example above would appear as:
  949. @smallexample
  950. $ @kbd{tar --create --verbose --file=collection.tar blues folk jazz}
  951. blues
  952. folk
  953. jazz
  954. @end smallexample
  955. This example is just like the example we showed which did not use
  956. @option{--verbose}, except that @command{tar} generated the remaining lines
  957. @iftex
  958. (note the different font styles).
  959. @end iftex
  960. @ifinfo
  961. .
  962. @end ifinfo
  963. In the rest of the examples in this chapter, we will frequently use
  964. @code{verbose} mode so we can show actions or @command{tar} responses that
  965. you would otherwise not see, and which are important for you to
  966. understand.
  967. @node short create
  968. @subsection Short Forms with @samp{create}
  969. As we said before, the @option{--create} (@option{-c}) operation is one of the most
  970. basic uses of @command{tar}, and you will use it countless times.
  971. Eventually, you will probably want to use abbreviated (or ``short'')
  972. forms of options. A full discussion of the three different forms that
  973. options can take appears in @ref{Styles}; for now, here is what the
  974. previous example (including the @option{--verbose} (@option{-v}) option) looks like
  975. using short option forms:
  976. @smallexample
  977. $ @kbd{tar -cvf collection.tar blues folk jazz}
  978. blues
  979. folk
  980. jazz
  981. @end smallexample
  982. @noindent
  983. As you can see, the system responds the same no matter whether you use
  984. long or short option forms.
  985. @FIXME{i don't like how this is worded:} One difference between using
  986. short and long option forms is that, although the exact placement of
  987. arguments following options is no more specific when using short forms,
  988. it is easier to become confused and make a mistake when using short
  989. forms. For example, suppose you attempted the above example in the
  990. following way:
  991. @smallexample
  992. $ @kbd{tar -cfv collection.tar blues folk jazz}
  993. @end smallexample
  994. @noindent
  995. In this case, @command{tar} will make an archive file called @file{v},
  996. containing the files @file{blues}, @file{folk}, and @file{jazz}, because
  997. the @samp{v} is the closest ``file name'' to the @option{-f} option, and
  998. is thus taken to be the chosen archive file name. @command{tar} will try
  999. to add a file called @file{collection.tar} to the @file{v} archive file;
  1000. if the file @file{collection.tar} did not already exist, @command{tar} will
  1001. report an error indicating that this file does not exist. If the file
  1002. @file{collection.tar} does already exist (e.g., from a previous command
  1003. you may have run), then @command{tar} will add this file to the archive.
  1004. Because the @option{-v} option did not get registered, @command{tar} will not
  1005. run under @samp{verbose} mode, and will not report its progress.
  1006. The end result is that you may be quite confused about what happened,
  1007. and possibly overwrite a file. To illustrate this further, we will show
  1008. you how an example we showed previously would look using short forms.
  1009. This example,
  1010. @smallexample
  1011. $ @kbd{tar blues --create folk --file=collection.tar jazz}
  1012. @end smallexample
  1013. @noindent
  1014. is confusing as it is. When shown using short forms, however, it
  1015. becomes much more so:
  1016. @smallexample
  1017. $ @kbd{tar blues -c folk -f collection.tar jazz}
  1018. @end smallexample
  1019. @noindent
  1020. It would be very easy to put the wrong string of characters
  1021. immediately following the @option{-f}, but doing that could sacrifice
  1022. valuable data.
  1023. For this reason, we recommend that you pay very careful attention to
  1024. the order of options and placement of file and archive names,
  1025. especially when using short option forms. Not having the option name
  1026. written out mnemonically can affect how well you remember which option
  1027. does what, and therefore where different names have to be placed.
  1028. @node create dir
  1029. @subsection Archiving Directories
  1030. @cindex Archiving Directories
  1031. @cindex Directories, Archiving
  1032. You can archive a directory by specifying its directory name as a
  1033. file name argument to @command{tar}. The files in the directory will be
  1034. archived relative to the working directory, and the directory will be
  1035. re-created along with its contents when the archive is extracted.
  1036. To archive a directory, first move to its superior directory. If you
  1037. have followed the previous instructions in this tutorial, you should
  1038. type:
  1039. @smallexample
  1040. $ @kbd{cd ..}
  1041. $
  1042. @end smallexample
  1043. @noindent
  1044. This will put you into the directory which contains @file{practice},
  1045. i.e., your home directory. Once in the superior directory, you can
  1046. specify the subdirectory, @file{practice}, as a file name argument. To
  1047. store @file{practice} in the new archive file @file{music.tar}, type:
  1048. @smallexample
  1049. $ @kbd{tar --create --verbose --file=music.tar practice}
  1050. @end smallexample
  1051. @noindent
  1052. @command{tar} should output:
  1053. @smallexample
  1054. practice/
  1055. practice/blues
  1056. practice/folk
  1057. practice/jazz
  1058. practice/collection.tar
  1059. @end smallexample
  1060. Note that the archive thus created is not in the subdirectory
  1061. @file{practice}, but rather in the current working directory---the
  1062. directory from which @command{tar} was invoked. Before trying to archive a
  1063. directory from its superior directory, you should make sure you have
  1064. write access to the superior directory itself, not only the directory
  1065. you are trying archive with @command{tar}. For example, you will probably
  1066. not be able to store your home directory in an archive by invoking
  1067. @command{tar} from the root directory; @xref{absolute}. (Note
  1068. also that @file{collection.tar}, the original archive file, has itself
  1069. been archived. @command{tar} will accept any file as a file to be
  1070. archived, regardless of its content. When @file{music.tar} is
  1071. extracted, the archive file @file{collection.tar} will be re-written
  1072. into the file system).
  1073. If you give @command{tar} a command such as
  1074. @smallexample
  1075. $ @kbd{tar --create --file=foo.tar .}
  1076. @end smallexample
  1077. @noindent
  1078. @command{tar} will report @samp{tar: ./foo.tar is the archive; not
  1079. dumped}. This happens because @command{tar} creates the archive
  1080. @file{foo.tar} in the current directory before putting any files into
  1081. it. Then, when @command{tar} attempts to add all the files in the
  1082. directory @file{.} to the archive, it notices that the file
  1083. @file{./foo.tar} is the same as the archive @file{foo.tar}, and skips
  1084. it. (It makes no sense to put an archive into itself.) @GNUTAR{}
  1085. will continue in this case, and create the archive
  1086. normally, except for the exclusion of that one file. (@emph{Please
  1087. note:} Other implementations of @command{tar} may not be so clever;
  1088. they will enter an infinite loop when this happens, so you should not
  1089. depend on this behavior unless you are certain you are running
  1090. @GNUTAR{}. In general, it is wise to always place the archive outside
  1091. of the directory being dumped.
  1092. @node list
  1093. @section How to List Archives
  1094. @opindex list
  1095. Frequently, you will find yourself wanting to determine exactly what a
  1096. particular archive contains. You can use the @option{--list}
  1097. (@option{-t}) operation to get the member names as they currently
  1098. appear in the archive, as well as various attributes of the files at
  1099. the time they were archived. For example, you can examine the archive
  1100. @file{collection.tar} that you created in the last section with the
  1101. command,
  1102. @smallexample
  1103. $ @kbd{tar --list --file=collection.tar}
  1104. @end smallexample
  1105. @noindent
  1106. The output of @command{tar} would then be:
  1107. @smallexample
  1108. blues
  1109. folk
  1110. jazz
  1111. @end smallexample
  1112. @noindent
  1113. The archive @file{bfiles.tar} would list as follows:
  1114. @smallexample
  1115. ./birds
  1116. baboon
  1117. ./box
  1118. @end smallexample
  1119. @noindent
  1120. Be sure to use a @option{--file=@var{archive-name}} (@option{-f
  1121. @var{archive-name}}) option just as with @option{--create}
  1122. (@option{-c}) to specify the name of the archive.
  1123. @xopindex{list, using with @option{--verbose}}
  1124. @xopindex{verbose, using with @option{--list}}
  1125. If you use the @option{--verbose} (@option{-v}) option with
  1126. @option{--list}, then @command{tar} will print out a listing
  1127. reminiscent of @w{@samp{ls -l}}, showing owner, file size, and so
  1128. forth. This output is described in detail in @ref{verbose member listing}.
  1129. If you had used @option{--verbose} (@option{-v}) mode, the example
  1130. above would look like:
  1131. @smallexample
  1132. $ @kbd{tar --list --verbose --file=collection.tar folk}
  1133. -rw-r--r-- myself user 62 1990-05-23 10:55 folk
  1134. @end smallexample
  1135. @cindex listing member and file names
  1136. @anchor{listing member and file names}
  1137. It is important to notice that the output of @kbd{tar --list
  1138. --verbose} does not necessarily match that produced by @kbd{tar
  1139. --create --verbose} while creating the archive. It is because
  1140. @GNUTAR{}, unless told explicitly not to do so, removes some directory
  1141. prefixes from file names before storing them in the archive
  1142. (@xref{absolute}, for more information). In other
  1143. words, in verbose mode @GNUTAR{} shows @dfn{file names} when creating
  1144. an archive and @dfn{member names} when listing it. Consider this
  1145. example:
  1146. @smallexample
  1147. @group
  1148. $ @kbd{tar cfv archive /etc/mail}
  1149. tar: Removing leading `/' from member names
  1150. /etc/mail/
  1151. /etc/mail/sendmail.cf
  1152. /etc/mail/aliases
  1153. $ @kbd{tar tf archive}
  1154. etc/mail/
  1155. etc/mail/sendmail.cf
  1156. etc/mail/aliases
  1157. @end group
  1158. @end smallexample
  1159. @opindex show-stored-names
  1160. This default behavior can sometimes be inconvenient. You can force
  1161. @GNUTAR{} show member names when creating archive by supplying
  1162. @option{--show-stored-names} option.
  1163. @table @option
  1164. @item --show-stored-names
  1165. Print member (as opposed to @emph{file}) names when creating the archive.
  1166. @end table
  1167. @cindex File name arguments, using @option{--list} with
  1168. @xopindex{list, using with file name arguments}
  1169. You can specify one or more individual member names as arguments when
  1170. using @samp{list}. In this case, @command{tar} will only list the
  1171. names of members you identify. For example, @w{@kbd{tar --list
  1172. --file=afiles.tar apple}} would only print @file{apple}.
  1173. Because @command{tar} preserves file names, these must be specified as
  1174. they appear in the archive (i.e., relative to the directory from which
  1175. the archive was created). Therefore, it is essential when specifying
  1176. member names to @command{tar} that you give the exact member names.
  1177. For example, @w{@kbd{tar --list --file=bfiles.tar birds}} would produce an
  1178. error message something like @samp{tar: birds: Not found in archive},
  1179. because there is no member named @file{birds}, only one named
  1180. @file{./birds}. While the names @file{birds} and @file{./birds} name
  1181. the same file, @emph{member} names by default are compared verbatim.
  1182. However, @w{@kbd{tar --list --file=bfiles.tar baboon}} would respond
  1183. with @file{baboon}, because this exact member name is in the archive file
  1184. @file{bfiles.tar}. If you are not sure of the exact file name,
  1185. use @dfn{globbing patterns}, for example:
  1186. @smallexample
  1187. $ @kbd{tar --list --file=bfiles.tar --wildcards '*b*'}
  1188. @end smallexample
  1189. @noindent
  1190. will list all members whose name contains @samp{b}. @xref{wildcards},
  1191. for a detailed discussion of globbing patterns and related
  1192. @command{tar} command line options.
  1193. @menu
  1194. * list dir::
  1195. @end menu
  1196. @node list dir
  1197. @unnumberedsubsec Listing the Contents of a Stored Directory
  1198. To get information about the contents of an archived directory,
  1199. use the directory name as a file name argument in conjunction with
  1200. @option{--list} (@option{-t}). To find out file attributes, include the
  1201. @option{--verbose} (@option{-v}) option.
  1202. For example, to find out about files in the directory @file{practice}, in
  1203. the archive file @file{music.tar}, type:
  1204. @smallexample
  1205. $ @kbd{tar --list --verbose --file=music.tar practice}
  1206. @end smallexample
  1207. @command{tar} responds:
  1208. @smallexample
  1209. drwxrwxrwx myself user 0 1990-05-31 21:49 practice/
  1210. -rw-r--r-- myself user 42 1990-05-21 13:29 practice/blues
  1211. -rw-r--r-- myself user 62 1990-05-23 10:55 practice/folk
  1212. -rw-r--r-- myself user 40 1990-05-21 13:30 practice/jazz
  1213. -rw-r--r-- myself user 10240 1990-05-31 21:49 practice/collection.tar
  1214. @end smallexample
  1215. When you use a directory name as a file name argument, @command{tar} acts on
  1216. all the files (including sub-directories) in that directory.
  1217. @node extract
  1218. @section How to Extract Members from an Archive
  1219. @UNREVISED
  1220. @cindex Extraction
  1221. @cindex Retrieving files from an archive
  1222. @cindex Resurrecting files from an archive
  1223. @opindex extract
  1224. Creating an archive is only half the job---there is no point in storing
  1225. files in an archive if you can't retrieve them. The act of retrieving
  1226. members from an archive so they can be used and manipulated as
  1227. unarchived files again is called @dfn{extraction}. To extract files
  1228. from an archive, use the @option{--extract} (@option{--get} or
  1229. @option{-x}) operation. As with @option{--create}, specify the name
  1230. of the archive with @option{--file} (@option{-f}) option. Extracting
  1231. an archive does not modify the archive in any way; you can extract it
  1232. multiple times if you want or need to.
  1233. Using @option{--extract}, you can extract an entire archive, or specific
  1234. files. The files can be directories containing other files, or not. As
  1235. with @option{--create} (@option{-c}) and @option{--list} (@option{-t}), you may use the short or the
  1236. long form of the operation without affecting the performance.
  1237. @menu
  1238. * extracting archives::
  1239. * extracting files::
  1240. * extract dir::
  1241. * extracting untrusted archives::
  1242. * failing commands::
  1243. @end menu
  1244. @node extracting archives
  1245. @subsection Extracting an Entire Archive
  1246. To extract an entire archive, specify the archive file name only, with
  1247. no individual file names as arguments. For example,
  1248. @smallexample
  1249. $ @kbd{tar -xvf collection.tar}
  1250. @end smallexample
  1251. @noindent
  1252. produces this:
  1253. @smallexample
  1254. -rw-r--r-- me user 28 1996-10-18 16:31 jazz
  1255. -rw-r--r-- me user 21 1996-09-23 16:44 blues
  1256. -rw-r--r-- me user 20 1996-09-23 16:44 folk
  1257. @end smallexample
  1258. @node extracting files
  1259. @subsection Extracting Specific Files
  1260. To extract specific archive members, give their exact member names as
  1261. arguments, as printed by @option{--list} (@option{-t}). If you had
  1262. mistakenly deleted one of the files you had placed in the archive
  1263. @file{collection.tar} earlier (say, @file{blues}), you can extract it
  1264. from the archive without changing the archive's structure. Its
  1265. contents will be identical to the original file @file{blues} that you
  1266. deleted.
  1267. First, make sure you are in the @file{practice} directory, and list the
  1268. files in the directory. Now, delete the file, @samp{blues}, and list
  1269. the files in the directory again.
  1270. You can now extract the member @file{blues} from the archive file
  1271. @file{collection.tar} like this:
  1272. @smallexample
  1273. $ @kbd{tar --extract --file=collection.tar blues}
  1274. @end smallexample
  1275. @noindent
  1276. If you list the files in the directory again, you will see that the file
  1277. @file{blues} has been restored, with its original permissions, data
  1278. modification times, and owner.@footnote{This is only accidentally
  1279. true, but not in general. Whereas modification times are always
  1280. restored, in most cases, one has to be root for restoring the owner,
  1281. and use a special option for restoring permissions. Here, it just
  1282. happens that the restoring user is also the owner of the archived
  1283. members, and that the current @code{umask} is compatible with original
  1284. permissions.} (These parameters will be identical to those which
  1285. the file had when you originally placed it in the archive; any changes
  1286. you may have made before deleting the file from the file system,
  1287. however, will @emph{not} have been made to the archive member.) The
  1288. archive file, @samp{collection.tar}, is the same as it was before you
  1289. extracted @samp{blues}. You can confirm this by running @command{tar} with
  1290. @option{--list} (@option{-t}).
  1291. Remember that as with other operations, specifying the exact member
  1292. name is important. @w{@kbd{tar --extract --file=bfiles.tar birds}}
  1293. will fail, because there is no member named @file{birds}. To extract
  1294. the member named @file{./birds}, you must specify @w{@kbd{tar
  1295. --extract --file=bfiles.tar ./birds}}. If you don't remember the
  1296. exact member names, use @option{--list} (@option{-t}) option
  1297. (@pxref{list}). You can also extract those members that match a
  1298. specific @dfn{globbing pattern}. For example, to extract from
  1299. @file{bfiles.tar} all files that begin with @samp{b}, no matter their
  1300. directory prefix, you could type:
  1301. @smallexample
  1302. $ @kbd{tar -x -f bfiles.tar --wildcards --no-anchored 'b*'}
  1303. @end smallexample
  1304. @noindent
  1305. Here, @option{--wildcards} instructs @command{tar} to treat
  1306. command line arguments as globbing patterns and @option{--no-anchored}
  1307. informs it that the patterns apply to member names after any @samp{/}
  1308. delimiter. The use of globbing patterns is discussed in detail in
  1309. @xref{wildcards}.
  1310. You can extract a file to standard output by combining the above options
  1311. with the @option{--to-stdout} (@option{-O}) option (@pxref{Writing to Standard
  1312. Output}).
  1313. If you give the @option{--verbose} option, then @option{--extract}
  1314. will print the names of the archive members as it extracts them.
  1315. @node extract dir
  1316. @subsection Extracting Files that are Directories
  1317. Extracting directories which are members of an archive is similar to
  1318. extracting other files. The main difference to be aware of is that if
  1319. the extracted directory has the same name as any directory already in
  1320. the working directory, then files in the extracted directory will be
  1321. placed into the directory of the same name. Likewise, if there are
  1322. files in the pre-existing directory with the same names as the members
  1323. which you extract, the files from the extracted archive will replace
  1324. the files already in the working directory (and possible
  1325. subdirectories). This will happen regardless of whether or not the
  1326. files in the working directory were more recent than those extracted
  1327. (there exist, however, special options that alter this behavior
  1328. @pxref{Writing}).
  1329. However, if a file was stored with a directory name as part of its file
  1330. name, and that directory does not exist under the working directory when
  1331. the file is extracted, @command{tar} will create the directory.
  1332. We can demonstrate how to use @option{--extract} to extract a directory
  1333. file with an example. Change to the @file{practice} directory if you
  1334. weren't there, and remove the files @file{folk} and @file{jazz}. Then,
  1335. go back to the parent directory and extract the archive
  1336. @file{music.tar}. You may either extract the entire archive, or you may
  1337. extract only the files you just deleted. To extract the entire archive,
  1338. don't give any file names as arguments after the archive name
  1339. @file{music.tar}. To extract only the files you deleted, use the
  1340. following command:
  1341. @smallexample
  1342. $ @kbd{tar -xvf music.tar practice/folk practice/jazz}
  1343. practice/folk
  1344. practice/jazz
  1345. @end smallexample
  1346. @noindent
  1347. If you were to specify two @option{--verbose} (@option{-v}) options, @command{tar}
  1348. would have displayed more detail about the extracted files, as shown
  1349. in the example below:
  1350. @smallexample
  1351. $ @kbd{tar -xvvf music.tar practice/folk practice/jazz}
  1352. -rw-r--r-- me user 28 1996-10-18 16:31 practice/jazz
  1353. -rw-r--r-- me user 20 1996-09-23 16:44 practice/folk
  1354. @end smallexample
  1355. @noindent
  1356. Because you created the directory with @file{practice} as part of the
  1357. file names of each of the files by archiving the @file{practice}
  1358. directory as @file{practice}, you must give @file{practice} as part
  1359. of the file names when you extract those files from the archive.
  1360. @node extracting untrusted archives
  1361. @subsection Extracting Archives from Untrusted Sources
  1362. Extracting files from archives can overwrite files that already exist.
  1363. If you receive an archive from an untrusted source, you should make a
  1364. new directory and extract into that directory, so that you don't have
  1365. to worry about the extraction overwriting one of your existing files.
  1366. For example, if @file{untrusted.tar} came from somewhere else on the
  1367. Internet, and you don't necessarily trust its contents, you can
  1368. extract it as follows:
  1369. @smallexample
  1370. $ @kbd{mkdir newdir}
  1371. $ @kbd{cd newdir}
  1372. $ @kbd{tar -xvf ../untrusted.tar}
  1373. @end smallexample
  1374. It is also a good practice to examine contents of the archive
  1375. before extracting it, using @option{--list} (@option{-t}) option, possibly combined
  1376. with @option{--verbose} (@option{-v}).
  1377. @node failing commands
  1378. @subsection Commands That Will Fail
  1379. Here are some sample commands you might try which will not work, and why
  1380. they won't work.
  1381. If you try to use this command,
  1382. @smallexample
  1383. $ @kbd{tar -xvf music.tar folk jazz}
  1384. @end smallexample
  1385. @noindent
  1386. you will get the following response:
  1387. @smallexample
  1388. tar: folk: Not found in archive
  1389. tar: jazz: Not found in archive
  1390. $
  1391. @end smallexample
  1392. @noindent
  1393. This is because these files were not originally @emph{in} the parent
  1394. directory @file{..}, where the archive is located; they were in the
  1395. @file{practice} directory, and their file names reflect this:
  1396. @smallexample
  1397. $ @kbd{tar -tvf music.tar}
  1398. practice/folk
  1399. practice/jazz
  1400. practice/rock
  1401. @end smallexample
  1402. @FIXME{make sure the above works when going through the examples in
  1403. order...}
  1404. @noindent
  1405. Likewise, if you try to use this command,
  1406. @smallexample
  1407. $ @kbd{tar -tvf music.tar folk jazz}
  1408. @end smallexample
  1409. @noindent
  1410. you would get a similar response. Members with those names are not in the
  1411. archive. You must use the correct member names, or wildcards, in order
  1412. to extract the files from the archive.
  1413. If you have forgotten the correct names of the files in the archive,
  1414. use @w{@kbd{tar --list --verbose}} to list them correctly.
  1415. @FIXME{more examples, here? hag thinks it's a good idea.}
  1416. @node going further
  1417. @section Going Further Ahead in this Manual
  1418. @FIXME{need to write up a node here about the things that are going to
  1419. be in the rest of the manual.}
  1420. @node tar invocation
  1421. @chapter Invoking @GNUTAR{}
  1422. @UNREVISED
  1423. This chapter is about how one invokes the @GNUTAR{}
  1424. command, from the command synopsis (@pxref{Synopsis}). There are
  1425. numerous options, and many styles for writing them. One mandatory
  1426. option specifies the operation @command{tar} should perform
  1427. (@pxref{Operation Summary}), other options are meant to detail how
  1428. this operation should be performed (@pxref{Option Summary}).
  1429. Non-option arguments are not always interpreted the same way,
  1430. depending on what the operation is.
  1431. You will find in this chapter everything about option styles and rules for
  1432. writing them (@pxref{Styles}). On the other hand, operations and options
  1433. are fully described elsewhere, in other chapters. Here, you will find
  1434. only synthetic descriptions for operations and options, together with
  1435. pointers to other parts of the @command{tar} manual.
  1436. Some options are so special they are fully described right in this
  1437. chapter. They have the effect of inhibiting the normal operation of
  1438. @command{tar} or else, they globally alter the amount of feedback the user
  1439. receives about what is going on. These are the @option{--help} and
  1440. @option{--version} (@pxref{help}), @option{--verbose} (@pxref{verbose})
  1441. and @option{--interactive} options (@pxref{interactive}).
  1442. @menu
  1443. * Synopsis::
  1444. * using tar options::
  1445. * Styles::
  1446. * All Options::
  1447. * help::
  1448. * defaults::
  1449. * verbose::
  1450. * interactive::
  1451. @end menu
  1452. @node Synopsis
  1453. @section General Synopsis of @command{tar}
  1454. The @GNUTAR{} program is invoked as either one of:
  1455. @smallexample
  1456. @kbd{tar @var{option}@dots{} [@var{name}]@dots{}}
  1457. @kbd{tar @var{letter}@dots{} [@var{argument}]@dots{} [@var{option}]@dots{} [@var{name}]@dots{}}
  1458. @end smallexample
  1459. The second form is for when old options are being used.
  1460. You can use @command{tar} to store files in an archive, to extract them from
  1461. an archive, and to do other types of archive manipulation. The primary
  1462. argument to @command{tar}, which is called the @dfn{operation}, specifies
  1463. which action to take. The other arguments to @command{tar} are either
  1464. @dfn{options}, which change the way @command{tar} performs an operation,
  1465. or file names or archive members, which specify the files or members
  1466. @command{tar} is to act on.
  1467. You can actually type in arguments in any order, even if in this manual
  1468. the options always precede the other arguments, to make examples easier
  1469. to understand. Further, the option stating the main operation mode
  1470. (the @command{tar} main command) is usually given first.
  1471. Each @var{name} in the synopsis above is interpreted as an archive member
  1472. name when the main command is one of @option{--compare}
  1473. (@option{--diff}, @option{-d}), @option{--delete}, @option{--extract}
  1474. (@option{--get}, @option{-x}), @option{--list} (@option{-t}) or
  1475. @option{--update} (@option{-u}). When naming archive members, you
  1476. must give the exact name of the member in the archive, as it is
  1477. printed by @option{--list}. For @option{--append} (@option{-r}) and
  1478. @option{--create} (@option{-c}), these @var{name} arguments specify
  1479. the names of either files or directory hierarchies to place in the archive.
  1480. These files or hierarchies should already exist in the file system,
  1481. prior to the execution of the @command{tar} command.
  1482. @command{tar} interprets relative file names as being relative to the
  1483. working directory. @command{tar} will make all file names relative
  1484. (by removing leading slashes when archiving or restoring files),
  1485. unless you specify otherwise (using the @option{--absolute-names}
  1486. option). @xref{absolute}, for more information about
  1487. @option{--absolute-names}.
  1488. If you give the name of a directory as either a file name or a member
  1489. name, then @command{tar} acts recursively on all the files and directories
  1490. beneath that directory. For example, the name @file{/} identifies all
  1491. the files in the file system to @command{tar}.
  1492. The distinction between file names and archive member names is especially
  1493. important when shell globbing is used, and sometimes a source of confusion
  1494. for newcomers. @xref{wildcards}, for more information about globbing.
  1495. The problem is that shells may only glob using existing files in the
  1496. file system. Only @command{tar} itself may glob on archive members, so when
  1497. needed, you must ensure that wildcard characters reach @command{tar} without
  1498. being interpreted by the shell first. Using a backslash before @samp{*}
  1499. or @samp{?}, or putting the whole argument between quotes, is usually
  1500. sufficient for this.
  1501. Even if @var{name}s are often specified on the command line, they
  1502. can also be read from a text file in the file system, using the
  1503. @option{--files-from=@var{file-of-names}} (@option{-T @var{file-of-names}}) option.
  1504. If you don't use any file name arguments, @option{--append} (@option{-r}),
  1505. @option{--delete} and @option{--concatenate} (@option{--catenate},
  1506. @option{-A}) will do nothing, while @option{--create} (@option{-c})
  1507. will usually yield a diagnostic and inhibit @command{tar} execution.
  1508. The other operations of @command{tar} (@option{--list},
  1509. @option{--extract}, @option{--compare}, and @option{--update})
  1510. will act on the entire contents of the archive.
  1511. @cindex exit status
  1512. @cindex return status
  1513. Besides successful exits, @GNUTAR{} may fail for
  1514. many reasons. Some reasons correspond to bad usage, that is, when the
  1515. @command{tar} command is improperly written. Errors may be
  1516. encountered later, while encountering an error processing the archive
  1517. or the files. Some errors are recoverable, in which case the failure
  1518. is delayed until @command{tar} has completed all its work. Some
  1519. errors are such that it would not meaningful, or at least risky, to
  1520. continue processing: @command{tar} then aborts processing immediately.
  1521. All abnormal exits, whether immediate or delayed, should always be
  1522. clearly diagnosed on @code{stderr}, after a line stating the nature of
  1523. the error.
  1524. Possible exit codes of @GNUTAR{} are summarized in the following
  1525. table:
  1526. @table @asis
  1527. @item 0
  1528. @samp{Successful termination}.
  1529. @item 1
  1530. @samp{Some files differ}. If tar was invoked with @option{--compare}
  1531. (@option{--diff}, @option{-d}) command line option, this means that
  1532. some files in the archive differ from their disk counterparts
  1533. (@pxref{compare}). If tar was given @option{--create},
  1534. @option{--append} or @option{--update} option, this exit code means
  1535. that some files were changed while being archived and so the resulting
  1536. archive does not contain the exact copy of the file set.
  1537. @item 2
  1538. @samp{Fatal error}. This means that some fatal, unrecoverable error
  1539. occurred.
  1540. @end table
  1541. If @command{tar} has invoked a subprocess and that subprocess exited with a
  1542. nonzero exit code, @command{tar} exits with that code as well.
  1543. This can happen, for example, if @command{tar} was given some
  1544. compression option (@pxref{gzip}) and the external compressor program
  1545. failed. Another example is @command{rmt} failure during backup to the
  1546. remote device (@pxref{Remote Tape Server}).
  1547. @node using tar options
  1548. @section Using @command{tar} Options
  1549. @GNUTAR{} has a total of eight operating modes which
  1550. allow you to perform a variety of tasks. You are required to choose
  1551. one operating mode each time you employ the @command{tar} program by
  1552. specifying one, and only one operation as an argument to the
  1553. @command{tar} command (two lists of four operations each may be found
  1554. at @ref{frequent operations} and @ref{Operations}). Depending on
  1555. circumstances, you may also wish to customize how the chosen operating
  1556. mode behaves. For example, you may wish to change the way the output
  1557. looks, or the format of the files that you wish to archive may require
  1558. you to do something special in order to make the archive look right.
  1559. You can customize and control @command{tar}'s performance by running
  1560. @command{tar} with one or more options (such as @option{--verbose}
  1561. (@option{-v}), which we used in the tutorial). As we said in the
  1562. tutorial, @dfn{options} are arguments to @command{tar} which are (as
  1563. their name suggests) optional. Depending on the operating mode, you
  1564. may specify one or more options. Different options will have different
  1565. effects, but in general they all change details of the operation, such
  1566. as archive format, archive name, or level of user interaction. Some
  1567. options make sense with all operating modes, while others are
  1568. meaningful only with particular modes. You will likely use some
  1569. options frequently, while you will only use others infrequently, or
  1570. not at all. (A full list of options is available in @pxref{All Options}.)
  1571. @vrindex TAR_OPTIONS, environment variable
  1572. @anchor{TAR_OPTIONS}
  1573. The @env{TAR_OPTIONS} environment variable specifies default options to
  1574. be placed in front of any explicit options. For example, if
  1575. @code{TAR_OPTIONS} is @samp{-v --unlink-first}, @command{tar} behaves as
  1576. if the two options @option{-v} and @option{--unlink-first} had been
  1577. specified before any explicit options. Option specifications are
  1578. separated by whitespace. A backslash escapes the next character, so it
  1579. can be used to specify an option containing whitespace or a backslash.
  1580. Note that @command{tar} options are case sensitive. For example, the
  1581. options @option{-T} and @option{-t} are different; the first requires an
  1582. argument for stating the name of a file providing a list of @var{name}s,
  1583. while the second does not require an argument and is another way to
  1584. write @option{--list} (@option{-t}).
  1585. In addition to the eight operations, there are many options to
  1586. @command{tar}, and three different styles for writing both: long (mnemonic)
  1587. form, short form, and old style. These styles are discussed below.
  1588. Both the options and the operations can be written in any of these three
  1589. styles.
  1590. @FIXME{menu at end of this node. need to think of an actual outline
  1591. for this chapter; probably do that after stuff from chapter 4 is
  1592. incorporated.}
  1593. @node Styles
  1594. @section The Three Option Styles
  1595. There are three styles for writing operations and options to the command
  1596. line invoking @command{tar}. The different styles were developed at
  1597. different times during the history of @command{tar}. These styles will be
  1598. presented below, from the most recent to the oldest.
  1599. Some options must take an argument. (For example, @option{--file}
  1600. (@option{-f})) takes the name of an archive file as an argument. If
  1601. you do not supply an archive file name, @command{tar} will use a
  1602. default, but this can be confusing; thus, we recommend that you always
  1603. supply a specific archive file name.) Where you @emph{place} the
  1604. arguments generally depends on which style of options you choose. We
  1605. will detail specific information relevant to each option style in the
  1606. sections on the different option styles, below. The differences are
  1607. subtle, yet can often be very important; incorrect option placement
  1608. can cause you to overwrite a number of important files. We urge you
  1609. to note these differences, and only use the option style(s) which
  1610. makes the most sense to you until you feel comfortable with the others.
  1611. Some options @emph{may} take an argument. Such options may have at
  1612. most long and short forms, they do not have old style equivalent. The
  1613. rules for specifying an argument for such options are stricter than
  1614. those for specifying mandatory arguments. Please, pay special
  1615. attention to them.
  1616. @menu
  1617. * Long Options:: Long Option Style
  1618. * Short Options:: Short Option Style
  1619. * Old Options:: Old Option Style
  1620. * Mixing:: Mixing Option Styles
  1621. @end menu
  1622. @node Long Options
  1623. @subsection Long Option Style
  1624. Each option has at least one @dfn{long} (or @dfn{mnemonic}) name starting with two
  1625. dashes in a row, e.g., @option{--list}. The long names are more clear than
  1626. their corresponding short or old names. It sometimes happens that a
  1627. single long option has many different names which are
  1628. synonymous, such as @option{--compare} and @option{--diff}. In addition,
  1629. long option names can be given unique abbreviations. For example,
  1630. @option{--cre} can be used in place of @option{--create} because there is no
  1631. other long option which begins with @samp{cre}. (One way to find
  1632. this out is by trying it and seeing what happens; if a particular
  1633. abbreviation could represent more than one option, @command{tar} will tell
  1634. you that that abbreviation is ambiguous and you'll know that that
  1635. abbreviation won't work. You may also choose to run @samp{tar --help}
  1636. to see a list of options. Be aware that if you run @command{tar} with a
  1637. unique abbreviation for the long name of an option you didn't want to
  1638. use, you are stuck; @command{tar} will perform the command as ordered.)
  1639. Long options are meant to be obvious and easy to remember, and their
  1640. meanings are generally easier to discern than those of their
  1641. corresponding short options (see below). For example:
  1642. @smallexample
  1643. $ @kbd{tar --create --verbose --blocking-factor=20 --file=/dev/rmt0}
  1644. @end smallexample
  1645. @noindent
  1646. gives a fairly good set of hints about what the command does, even
  1647. for those not fully acquainted with @command{tar}.
  1648. Long options which require arguments take those arguments
  1649. immediately following the option name. There are two ways of
  1650. specifying a mandatory argument. It can be separated from the
  1651. option name either by an equal sign, or by any amount of
  1652. white space characters. For example, the @option{--file} option (which
  1653. tells the name of the @command{tar} archive) is given a file such as
  1654. @file{archive.tar} as argument by using any of the following notations:
  1655. @option{--file=archive.tar} or @option{--file archive.tar}.
  1656. In contrast, optional arguments must always be introduced using
  1657. an equal sign. For example, the @option{--backup} option takes
  1658. an optional argument specifying backup type. It must be used
  1659. as @option{--backup=@var{backup-type}}.
  1660. @node Short Options
  1661. @subsection Short Option Style
  1662. Most options also have a @dfn{short option} name. Short options start with
  1663. a single dash, and are followed by a single character, e.g., @option{-t}
  1664. (which is equivalent to @option{--list}). The forms are absolutely
  1665. identical in function; they are interchangeable.
  1666. The short option names are faster to type than long option names.
  1667. Short options which require arguments take their arguments immediately
  1668. following the option, usually separated by white space. It is also
  1669. possible to stick the argument right after the short option name, using
  1670. no intervening space. For example, you might write @w{@option{-f
  1671. archive.tar}} or @option{-farchive.tar} instead of using
  1672. @option{--file=archive.tar}. Both @option{--file=@var{archive-name}} and
  1673. @w{@option{-f @var{archive-name}}} denote the option which indicates a
  1674. specific archive, here named @file{archive.tar}.
  1675. Short options which take optional arguments take their arguments
  1676. immediately following the option letter, @emph{without any intervening
  1677. white space characters}.
  1678. Short options' letters may be clumped together, but you are not
  1679. required to do this (as compared to old options; see below). When
  1680. short options are clumped as a set, use one (single) dash for them
  1681. all, e.g., @w{@samp{@command{tar} -cvf}}. Only the last option in
  1682. such a set is allowed to have an argument@footnote{Clustering many
  1683. options, the last of which has an argument, is a rather opaque way to
  1684. write options. Some wonder if @acronym{GNU} @code{getopt} should not
  1685. even be made helpful enough for considering such usages as invalid.}.
  1686. When the options are separated, the argument for each option which requires
  1687. an argument directly follows that option, as is usual for Unix programs.
  1688. For example:
  1689. @smallexample
  1690. $ @kbd{tar -c -v -b 20 -f /dev/rmt0}
  1691. @end smallexample
  1692. If you reorder short options' locations, be sure to move any arguments
  1693. that belong to them. If you do not move the arguments properly, you may
  1694. end up overwriting files.
  1695. @node Old Options
  1696. @subsection Old Option Style
  1697. @UNREVISED
  1698. Like short options, @dfn{old options} are single letters. However, old options
  1699. must be written together as a single clumped set, without spaces separating
  1700. them or dashes preceding them@footnote{Beware that if you precede options
  1701. with a dash, you are announcing the short option style instead of the
  1702. old option style; short options are decoded differently.}. This set
  1703. of letters must be the first to appear on the command line, after the
  1704. @command{tar} program name and some white space; old options cannot appear
  1705. anywhere else. The letter of an old option is exactly the same letter as
  1706. the corresponding short option. For example, the old option @samp{t} is
  1707. the same as the short option @option{-t}, and consequently, the same as the
  1708. long option @option{--list}. So for example, the command @w{@samp{tar
  1709. cv}} specifies the option @option{-v} in addition to the operation @option{-c}.
  1710. When options that need arguments are given together with the command,
  1711. all the associated arguments follow, in the same order as the options.
  1712. Thus, the example given previously could also be written in the old
  1713. style as follows:
  1714. @smallexample
  1715. $ @kbd{tar cvbf 20 /dev/rmt0}
  1716. @end smallexample
  1717. @noindent
  1718. Here, @samp{20} is the argument of @option{-b} and @samp{/dev/rmt0} is
  1719. the argument of @option{-f}.
  1720. On the other hand, this old style syntax makes it difficult to match
  1721. option letters with their corresponding arguments, and is often
  1722. confusing. In the command @w{@samp{tar cvbf 20 /dev/rmt0}}, for example,
  1723. @samp{20} is the argument for @option{-b}, @samp{/dev/rmt0} is the
  1724. argument for @option{-f}, and @option{-v} does not have a corresponding
  1725. argument. Even using short options like in @w{@samp{tar -c -v -b 20 -f
  1726. /dev/rmt0}} is clearer, putting all arguments next to the option they
  1727. pertain to.
  1728. If you want to reorder the letters in the old option argument, be
  1729. sure to reorder any corresponding argument appropriately.
  1730. This old way of writing @command{tar} options can surprise even experienced
  1731. users. For example, the two commands:
  1732. @smallexample
  1733. @kbd{tar cfz archive.tar.gz file}
  1734. @kbd{tar -cfz archive.tar.gz file}
  1735. @end smallexample
  1736. @noindent
  1737. are quite different. The first example uses @file{archive.tar.gz} as
  1738. the value for option @samp{f} and recognizes the option @samp{z}. The
  1739. second example, however, uses @file{z} as the value for option
  1740. @samp{f} --- probably not what was intended.
  1741. Old options are kept for compatibility with old versions of @command{tar}.
  1742. This second example could be corrected in many ways, among which the
  1743. following are equivalent:
  1744. @smallexample
  1745. @kbd{tar -czf archive.tar.gz file}
  1746. @kbd{tar -cf archive.tar.gz -z file}
  1747. @kbd{tar cf archive.tar.gz -z file}
  1748. @end smallexample
  1749. @cindex option syntax, traditional
  1750. As far as we know, all @command{tar} programs, @acronym{GNU} and
  1751. non-@acronym{GNU}, support old options. @GNUTAR{}
  1752. supports them not only for historical reasons, but also because many
  1753. people are used to them. For compatibility with Unix @command{tar},
  1754. the first argument is always treated as containing command and option
  1755. letters even if it doesn't start with @samp{-}. Thus, @samp{tar c} is
  1756. equivalent to @w{@samp{tar -c}:} both of them specify the
  1757. @option{--create} (@option{-c}) command to create an archive.
  1758. @node Mixing
  1759. @subsection Mixing Option Styles
  1760. All three styles may be intermixed in a single @command{tar} command,
  1761. so long as the rules for each style are fully
  1762. respected@footnote{Before @GNUTAR{} version 1.11.6,
  1763. a bug prevented intermixing old style options with long options in
  1764. some cases.}. Old style options and either of the modern styles of
  1765. options may be mixed within a single @command{tar} command. However,
  1766. old style options must be introduced as the first arguments only,
  1767. following the rule for old options (old options must appear directly
  1768. after the @command{tar} command and some white space). Modern options
  1769. may be given only after all arguments to the old options have been
  1770. collected. If this rule is not respected, a modern option might be
  1771. falsely interpreted as the value of the argument to one of the old
  1772. style options.
  1773. For example, all the following commands are wholly equivalent, and
  1774. illustrate the many combinations and orderings of option styles.
  1775. @smallexample
  1776. @kbd{tar --create --file=archive.tar}
  1777. @kbd{tar --create -f archive.tar}
  1778. @kbd{tar --create -farchive.tar}
  1779. @kbd{tar --file=archive.tar --create}
  1780. @kbd{tar --file=archive.tar -c}
  1781. @kbd{tar -c --file=archive.tar}
  1782. @kbd{tar -c -f archive.tar}
  1783. @kbd{tar -c -farchive.tar}
  1784. @kbd{tar -cf archive.tar}
  1785. @kbd{tar -cfarchive.tar}
  1786. @kbd{tar -f archive.tar --create}
  1787. @kbd{tar -f archive.tar -c}
  1788. @kbd{tar -farchive.tar --create}
  1789. @kbd{tar -farchive.tar -c}
  1790. @kbd{tar c --file=archive.tar}
  1791. @kbd{tar c -f archive.tar}
  1792. @kbd{tar c -farchive.tar}
  1793. @kbd{tar cf archive.tar}
  1794. @kbd{tar f archive.tar --create}
  1795. @kbd{tar f archive.tar -c}
  1796. @kbd{tar fc archive.tar}
  1797. @end smallexample
  1798. On the other hand, the following commands are @emph{not} equivalent to
  1799. the previous set:
  1800. @smallexample
  1801. @kbd{tar -f -c archive.tar}
  1802. @kbd{tar -fc archive.tar}
  1803. @kbd{tar -fcarchive.tar}
  1804. @kbd{tar -farchive.tarc}
  1805. @kbd{tar cfarchive.tar}
  1806. @end smallexample
  1807. @noindent
  1808. These last examples mean something completely different from what the
  1809. user intended (judging based on the example in the previous set which
  1810. uses long options, whose intent is therefore very clear). The first
  1811. four specify that the @command{tar} archive would be a file named
  1812. @option{-c}, @samp{c}, @samp{carchive.tar} or @samp{archive.tarc},
  1813. respectively. The first two examples also specify a single non-option,
  1814. @var{name} argument having the value @samp{archive.tar}. The last
  1815. example contains only old style option letters (repeating option
  1816. @samp{c} twice), not all of which are meaningful (eg., @samp{.},
  1817. @samp{h}, or @samp{i}), with no argument value. @FIXME{not sure i liked
  1818. the first sentence of this paragraph..}
  1819. @node All Options
  1820. @section All @command{tar} Options
  1821. The coming manual sections contain an alphabetical listing of all
  1822. @command{tar} operations and options, with brief descriptions and cross
  1823. references to more in-depth explanations in the body of the manual.
  1824. They also contain an alphabetically arranged table of the short option
  1825. forms with their corresponding long option. You can use this table as
  1826. a reference for deciphering @command{tar} commands in scripts.
  1827. @menu
  1828. * Operation Summary::
  1829. * Option Summary::
  1830. * Short Option Summary::
  1831. @end menu
  1832. @node Operation Summary
  1833. @subsection Operations
  1834. @table @option
  1835. @opsummary{append}
  1836. @item --append
  1837. @itemx -r
  1838. Appends files to the end of the archive. @xref{append}.
  1839. @opsummary{catenate}
  1840. @item --catenate
  1841. @itemx -A
  1842. Same as @option{--concatenate}. @xref{concatenate}.
  1843. @opsummary{compare}
  1844. @item --compare
  1845. @itemx -d
  1846. Compares archive members with their counterparts in the file
  1847. system, and reports differences in file size, mode, owner,
  1848. modification date and contents. @xref{compare}.
  1849. @opsummary{concatenate}
  1850. @item --concatenate
  1851. @itemx -A
  1852. Appends other @command{tar} archives to the end of the archive.
  1853. @xref{concatenate}.
  1854. @opsummary{create}
  1855. @item --create
  1856. @itemx -c
  1857. Creates a new @command{tar} archive. @xref{create}.
  1858. @opsummary{delete}
  1859. @item --delete
  1860. Deletes members from the archive. Don't try this on a archive on a
  1861. tape! @xref{delete}.
  1862. @opsummary{diff}
  1863. @item --diff
  1864. @itemx -d
  1865. Same @option{--compare}. @xref{compare}.
  1866. @opsummary{extract}
  1867. @item --extract
  1868. @itemx -x
  1869. Extracts members from the archive into the file system. @xref{extract}.
  1870. @opsummary{get}
  1871. @item --get
  1872. @itemx -x
  1873. Same as @option{--extract}. @xref{extract}.
  1874. @opsummary{list}
  1875. @item --list
  1876. @itemx -t
  1877. Lists the members in an archive. @xref{list}.
  1878. @opsummary{update}
  1879. @item --update
  1880. @itemx -u
  1881. Adds files to the end of the archive, but only if they are newer than
  1882. their counterparts already in the archive, or if they do not already
  1883. exist in the archive. @xref{update}.
  1884. @end table
  1885. @node Option Summary
  1886. @subsection @command{tar} Options
  1887. @table @option
  1888. @opsummary{absolute-names}
  1889. @item --absolute-names
  1890. @itemx -P
  1891. Normally when creating an archive, @command{tar} strips an initial
  1892. @samp{/} from member names. This option disables that behavior.
  1893. @xref{absolute}.
  1894. @opsummary{after-date}
  1895. @item --after-date
  1896. (See @option{--newer}, @pxref{after})
  1897. @opsummary{anchored}
  1898. @item --anchored
  1899. A pattern must match an initial subsequence of the name's components.
  1900. @xref{controlling pattern-matching}.
  1901. @opsummary{atime-preserve}
  1902. @item --atime-preserve
  1903. @itemx --atime-preserve=replace
  1904. @itemx --atime-preserve=system
  1905. Attempt to preserve the access time of files when reading them. This
  1906. option currently is effective only on files that you own, unless you
  1907. have superuser privileges.
  1908. @option{--atime-preserve=replace} remembers the access time of a file
  1909. before reading it, and then restores the access time afterwards. This
  1910. may cause problems if other programs are reading the file at the same
  1911. time, as the times of their accesses will be lost. On most platforms
  1912. restoring the access time also requires @command{tar} to restore the
  1913. data modification time too, so this option may also cause problems if
  1914. other programs are writing the file at the same time. (Tar attempts
  1915. to detect this situation, but cannot do so reliably due to race
  1916. conditions.) Worse, on most platforms restoring the access time also
  1917. updates the status change time, which means that this option is
  1918. incompatible with incremental backups.
  1919. @option{--atime-preserve=system} avoids changing time stamps on files,
  1920. without interfering with time stamp updates
  1921. caused by other programs, so it works better with incremental backups.
  1922. However, it requires a special @code{O_NOATIME} option from the
  1923. underlying operating and file system implementation, and it also requires
  1924. that searching directories does not update their access times. As of
  1925. this writing (November 2005) this works only with Linux, and only with
  1926. Linux kernels 2.6.8 and later. Worse, there is currently no reliable
  1927. way to know whether this feature actually works. Sometimes
  1928. @command{tar} knows that it does not work, and if you use
  1929. @option{--atime-preserve=system} then @command{tar} complains and
  1930. exits right away. But other times @command{tar} might think that the
  1931. option works when it actually does not.
  1932. Currently @option{--atime-preserve} with no operand defaults to
  1933. @option{--atime-preserve=replace}, but this may change in the future
  1934. as support for @option{--atime-preserve=system} improves.
  1935. If your operating system does not support
  1936. @option{--atime-preserve=@-system}, you might be able to preserve access
  1937. times reliably by by using the @command{mount} command. For example,
  1938. you can mount the file system read-only, or access the file system via
  1939. a read-only loopback mount, or use the @samp{noatime} mount option
  1940. available on some systems. However, mounting typically requires
  1941. superuser privileges and can be a pain to manage.
  1942. @opsummary{backup}
  1943. @item --backup=@var{backup-type}
  1944. Rather than deleting files from the file system, @command{tar} will
  1945. back them up using simple or numbered backups, depending upon
  1946. @var{backup-type}. @xref{backup}.
  1947. @opsummary{block-number}
  1948. @item --block-number
  1949. @itemx -R
  1950. With this option present, @command{tar} prints error messages for read errors
  1951. with the block number in the archive file. @xref{block-number}.
  1952. @opsummary{blocking-factor}
  1953. @item --blocking-factor=@var{blocking}
  1954. @itemx -b @var{blocking}
  1955. Sets the blocking factor @command{tar} uses to @var{blocking} x 512 bytes per
  1956. record. @xref{Blocking Factor}.
  1957. @opsummary{bzip2}
  1958. @item --bzip2
  1959. @itemx -j
  1960. This option tells @command{tar} to read or write archives through
  1961. @code{bzip2}. @xref{gzip}.
  1962. @opsummary{checkpoint}
  1963. @item --checkpoint[=@var{number}]
  1964. This option directs @command{tar} to print periodic checkpoint
  1965. messages as it reads through the archive. It is intended for when you
  1966. want a visual indication that @command{tar} is still running, but
  1967. don't want to see @option{--verbose} output. For a detailed
  1968. description, see @ref{Progress information}.
  1969. @opsummary{check-links}
  1970. @item --check-links
  1971. @itemx -l
  1972. If this option was given, @command{tar} will check the number of links
  1973. dumped for each processed file. If this number does not match the
  1974. total number of hard links for the file, a warning message will be
  1975. output @footnote{Earlier versions of @GNUTAR{} understood @option{-l} as a
  1976. synonym for @option{--one-file-system}. The current semantics, which
  1977. complies to UNIX98, was introduced with version
  1978. 1.15.91. @xref{Changes}, for more information.}.
  1979. @opsummary{compress}
  1980. @opsummary{uncompress}
  1981. @item --compress
  1982. @itemx --uncompress
  1983. @itemx -Z
  1984. @command{tar} will use the @command{compress} program when reading or
  1985. writing the archive. This allows you to directly act on archives
  1986. while saving space. @xref{gzip}.
  1987. @opsummary{confirmation}
  1988. @item --confirmation
  1989. (See @option{--interactive}.) @xref{interactive}.
  1990. @opsummary{delay-directory-restore}
  1991. @item --delay-directory-restore
  1992. Delay setting modification times and permissions of extracted
  1993. directories until the end of extraction. @xref{Directory Modification Times and Permissions}.
  1994. @opsummary{dereference}
  1995. @item --dereference
  1996. @itemx -h
  1997. When creating a @command{tar} archive, @command{tar} will archive the
  1998. file that a symbolic link points to, rather than archiving the
  1999. symlink. @xref{dereference}.
  2000. @opsummary{directory}
  2001. @item --directory=@var{dir}
  2002. @itemx -C @var{dir}
  2003. When this option is specified, @command{tar} will change its current directory
  2004. to @var{dir} before performing any operations. When this option is used
  2005. during archive creation, it is order sensitive. @xref{directory}.
  2006. @opsummary{exclude}
  2007. @item --exclude=@var{pattern}
  2008. When performing operations, @command{tar} will skip files that match
  2009. @var{pattern}. @xref{exclude}.
  2010. @opsummary{exclude-from}
  2011. @item --exclude-from=@var{file}
  2012. @itemx -X @var{file}
  2013. Similar to @option{--exclude}, except @command{tar} will use the list of
  2014. patterns in the file @var{file}. @xref{exclude}.
  2015. @opsummary{exclude-caches}
  2016. @item --exclude-caches
  2017. Exclude from dump any directory containing a valid cache directory
  2018. tag file, but still dump the directory node and the tag file itself.
  2019. @xref{exclude}.
  2020. @opsummary{exclude-caches-under}
  2021. @item --exclude-caches-under
  2022. Exclude from dump any directory containing a valid cache directory
  2023. tag file, but still dump the directory node itself.
  2024. @xref{exclude}.
  2025. @opsummary{exclude-caches-all}
  2026. @item --exclude-caches-all
  2027. Exclude from dump any directory containing a valid cache directory
  2028. tag file. @xref{exclude}.
  2029. @opsummary{exclude-tag}
  2030. @item --exclude-tag=@var{file}
  2031. Exclude from dump any directory containing file named @var{file}, but
  2032. dump the directory node and @var{file} itself. @xref{exclude}.
  2033. @opsummary{exclude-tag-under}
  2034. @item --exclude-tag-under=@var{file}
  2035. Exclude from dump the contents of any directory containing file
  2036. named @var{file}, but dump the directory node itself. @xref{exclude}.
  2037. @opsummary{exclude-tag-all}
  2038. @item --exclude-tag-all=@var{file}
  2039. Exclude from dump any directory containing file named @var{file}.
  2040. @xref{exclude}.
  2041. @opsummary{file}
  2042. @item --file=@var{archive}
  2043. @itemx -f @var{archive}
  2044. @command{tar} will use the file @var{archive} as the @command{tar} archive it
  2045. performs operations on, rather than @command{tar}'s compilation dependent
  2046. default. @xref{file tutorial}.
  2047. @opsummary{files-from}
  2048. @item --files-from=@var{file}
  2049. @itemx -T @var{file}
  2050. @command{tar} will use the contents of @var{file} as a list of archive members
  2051. or files to operate on, in addition to those specified on the
  2052. command-line. @xref{files}.
  2053. @opsummary{force-local}
  2054. @item --force-local
  2055. Forces @command{tar} to interpret the file name given to @option{--file}
  2056. as a local file, even if it looks like a remote tape drive name.
  2057. @xref{local and remote archives}.
  2058. @opsummary{format}
  2059. @item --format=@var{format}
  2060. @itemx -H @var{format}
  2061. Selects output archive format. @var{Format} may be one of the
  2062. following:
  2063. @table @samp
  2064. @item v7
  2065. Creates an archive that is compatible with Unix V7 @command{tar}.
  2066. @item oldgnu
  2067. Creates an archive that is compatible with GNU @command{tar} version
  2068. 1.12 or earlier.
  2069. @item gnu
  2070. Creates archive in GNU tar 1.13 format. Basically it is the same as
  2071. @samp{oldgnu} with the only difference in the way it handles long
  2072. numeric fields.
  2073. @item ustar
  2074. Creates a @acronym{POSIX.1-1988} compatible archive.
  2075. @item posix
  2076. Creates a @acronym{POSIX.1-2001 archive}.
  2077. @end table
  2078. @xref{Formats}, for a detailed discussion of these formats.
  2079. @opsummary{group}
  2080. @item --group=@var{group}
  2081. Files added to the @command{tar} archive will have a group @acronym{ID} of @var{group},
  2082. rather than the group from the source file. @var{group} is first decoded
  2083. as a group symbolic name, but if this interpretation fails, it has to be
  2084. a decimal numeric group @acronym{ID}. @xref{override}.
  2085. Also see the comments for the @option{--owner=@var{user}} option.
  2086. @opsummary{gzip}
  2087. @opsummary{gunzip}
  2088. @opsummary{ungzip}
  2089. @item --gzip
  2090. @itemx --gunzip
  2091. @itemx --ungzip
  2092. @itemx -z
  2093. This option tells @command{tar} to read or write archives through
  2094. @command{gzip}, allowing @command{tar} to directly operate on several
  2095. kinds of compressed archives transparently. @xref{gzip}.
  2096. @opsummary{help}
  2097. @item --help
  2098. @itemx -?
  2099. @command{tar} will print out a short message summarizing the operations and
  2100. options to @command{tar} and exit. @xref{help}.
  2101. @opsummary{ignore-case}
  2102. @item --ignore-case
  2103. Ignore case when matching member or file names with
  2104. patterns. @xref{controlling pattern-matching}.
  2105. @opsummary{ignore-command-error}
  2106. @item --ignore-command-error
  2107. Ignore exit codes of subprocesses. @xref{Writing to an External Program}.
  2108. @opsummary{ignore-failed-read}
  2109. @item --ignore-failed-read
  2110. Do not exit unsuccessfully merely because an unreadable file was encountered.
  2111. @xref{Reading}.
  2112. @opsummary{ignore-zeros}
  2113. @item --ignore-zeros
  2114. @itemx -i
  2115. With this option, @command{tar} will ignore zeroed blocks in the
  2116. archive, which normally signals EOF. @xref{Reading}.
  2117. @opsummary{incremental}
  2118. @item --incremental
  2119. @itemx -G
  2120. Informs @command{tar} that it is working with an old
  2121. @acronym{GNU}-format incremental backup archive. It is intended
  2122. primarily for backwards compatibility only. @xref{Incremental Dumps},
  2123. for a detailed discussion of incremental archives.
  2124. @opsummary{index-file}
  2125. @item --index-file=@var{file}
  2126. Send verbose output to @var{file} instead of to standard output.
  2127. @opsummary{info-script}
  2128. @opsummary{new-volume-script}
  2129. @item --info-script=@var{script-file}
  2130. @itemx --new-volume-script=@var{script-file}
  2131. @itemx -F @var{script-file}
  2132. When @command{tar} is performing multi-tape backups, @var{script-file} is run
  2133. at the end of each tape. If @var{script-file} exits with nonzero status,
  2134. @command{tar} fails immediately. @xref{info-script}, for a detailed
  2135. discussion of @var{script-file}.
  2136. @opsummary{interactive}
  2137. @item --interactive
  2138. @itemx --confirmation
  2139. @itemx -w
  2140. Specifies that @command{tar} should ask the user for confirmation before
  2141. performing potentially destructive options, such as overwriting files.
  2142. @xref{interactive}.
  2143. @opsummary{keep-newer-files}
  2144. @item --keep-newer-files
  2145. Do not replace existing files that are newer than their archive copies
  2146. when extracting files from an archive.
  2147. @opsummary{keep-old-files}
  2148. @item --keep-old-files
  2149. @itemx -k
  2150. Do not overwrite existing files when extracting files from an archive.
  2151. @xref{Keep Old Files}.
  2152. @opsummary{label}
  2153. @item --label=@var{name}
  2154. @itemx -V @var{name}
  2155. When creating an archive, instructs @command{tar} to write @var{name}
  2156. as a name record in the archive. When extracting or listing archives,
  2157. @command{tar} will only operate on archives that have a label matching
  2158. the pattern specified in @var{name}. @xref{Tape Files}.
  2159. @opsummary{listed-incremental}
  2160. @item --listed-incremental=@var{snapshot-file}
  2161. @itemx -g @var{snapshot-file}
  2162. During a @option{--create} operation, specifies that the archive that
  2163. @command{tar} creates is a new @acronym{GNU}-format incremental
  2164. backup, using @var{snapshot-file} to determine which files to backup.
  2165. With other operations, informs @command{tar} that the archive is in
  2166. incremental format. @xref{Incremental Dumps}.
  2167. @opsummary{mode}
  2168. @item --mode=@var{permissions}
  2169. When adding files to an archive, @command{tar} will use
  2170. @var{permissions} for the archive members, rather than the permissions
  2171. from the files. @var{permissions} can be specified either as an octal
  2172. number or as symbolic permissions, like with
  2173. @command{chmod}. @xref{override}.
  2174. @opsummary{mtime}
  2175. @item --mtime=@var{date}
  2176. When adding files to an archive, @command{tar} will use @var{date} as
  2177. the modification time of members when creating archives, instead of
  2178. their actual modification times. The value of @var{date} can be
  2179. either a textual date representation (@pxref{Date input formats}) or a
  2180. name of the existing file, starting with @samp{/} or @samp{.}. In the
  2181. latter case, the modification time of that file is used. @xref{override}.
  2182. @opsummary{multi-volume}
  2183. @item --multi-volume
  2184. @itemx -M
  2185. Informs @command{tar} that it should create or otherwise operate on a
  2186. multi-volume @command{tar} archive. @xref{Using Multiple Tapes}.
  2187. @opsummary{new-volume-script}
  2188. @item --new-volume-script
  2189. (see --info-script)
  2190. @opsummary{newer}
  2191. @item --newer=@var{date}
  2192. @itemx --after-date=@var{date}
  2193. @itemx -N
  2194. When creating an archive, @command{tar} will only add files that have changed
  2195. since @var{date}. If @var{date} begins with @samp{/} or @samp{.}, it
  2196. is taken to be the name of a file whose data modification time specifies
  2197. the date. @xref{after}.
  2198. @opsummary{newer-mtime}
  2199. @item --newer-mtime=@var{date}
  2200. Like @option{--newer}, but add only files whose
  2201. contents have changed (as opposed to just @option{--newer}, which will
  2202. also back up files for which any status information has
  2203. changed). @xref{after}.
  2204. @opsummary{no-anchored}
  2205. @item --no-anchored
  2206. An exclude pattern can match any subsequence of the name's components.
  2207. @xref{controlling pattern-matching}.
  2208. @opsummary{no-delay-directory-restore}
  2209. @item --no-delay-directory-restore
  2210. Modification times and permissions of extracted
  2211. directories are set when all files from this directory have been
  2212. extracted. This is the default.
  2213. @xref{Directory Modification Times and Permissions}.
  2214. @opsummary{no-ignore-case}
  2215. @item --no-ignore-case
  2216. Use case-sensitive matching.
  2217. @xref{controlling pattern-matching}.
  2218. @opsummary{no-ignore-command-error}
  2219. @item --no-ignore-command-error
  2220. Print warnings about subprocesses that terminated with a nonzero exit
  2221. code. @xref{Writing to an External Program}.
  2222. @opsummary{no-overwrite-dir}
  2223. @item --no-overwrite-dir
  2224. Preserve metadata of existing directories when extracting files
  2225. from an archive. @xref{Overwrite Old Files}.
  2226. @opsummary{no-quote-chars}
  2227. @item --no-quote-chars=@var{string}
  2228. Remove characters listed in @var{string} from the list of quoted
  2229. characters set by the previous @option{--quote-chars} option
  2230. (@pxref{quoting styles}).
  2231. @opsummary{no-recursion}
  2232. @item --no-recursion
  2233. With this option, @command{tar} will not recurse into directories.
  2234. @xref{recurse}.
  2235. @opsummary{no-same-owner}
  2236. @item --no-same-owner
  2237. @itemx -o
  2238. When extracting an archive, do not attempt to preserve the owner
  2239. specified in the @command{tar} archive. This the default behavior
  2240. for ordinary users.
  2241. @opsummary{no-same-permissions}
  2242. @item --no-same-permissions
  2243. When extracting an archive, subtract the user's umask from files from
  2244. the permissions specified in the archive. This is the default behavior
  2245. for ordinary users.
  2246. @opsummary{no-unquote}
  2247. @item --no-unquote
  2248. Treat all input file or member names literally, do not interpret
  2249. escape sequences. @xref{input name quoting}.
  2250. @opsummary{no-wildcards}
  2251. @item --no-wildcards
  2252. Do not use wildcards.
  2253. @xref{controlling pattern-matching}.
  2254. @opsummary{no-wildcards-match-slash}
  2255. @item --no-wildcards-match-slash
  2256. Wildcards do not match @samp{/}.
  2257. @xref{controlling pattern-matching}.
  2258. @opsummary{null}
  2259. @item --null
  2260. When @command{tar} is using the @option{--files-from} option, this option
  2261. instructs @command{tar} to expect file names terminated with @acronym{NUL}, so
  2262. @command{tar} can correctly work with file names that contain newlines.
  2263. @xref{nul}.
  2264. @opsummary{numeric-owner}
  2265. @item --numeric-owner
  2266. This option will notify @command{tar} that it should use numeric user
  2267. and group IDs when creating a @command{tar} file, rather than names.
  2268. @xref{Attributes}.
  2269. @item -o
  2270. The function of this option depends on the action @command{tar} is
  2271. performing. When extracting files, @option{-o} is a synonym for
  2272. @option{--no-same-owner}, i.e., it prevents @command{tar} from
  2273. restoring ownership of files being extracted.
  2274. When creating an archive, it is a synonym for
  2275. @option{--old-archive}. This behavior is for compatibility
  2276. with previous versions of @GNUTAR{}, and will be
  2277. removed in future releases.
  2278. @xref{Changes}, for more information.
  2279. @opsummary{occurrence}
  2280. @item --occurrence[=@var{number}]
  2281. This option can be used in conjunction with one of the subcommands
  2282. @option{--delete}, @option{--diff}, @option{--extract} or
  2283. @option{--list} when a list of files is given either on the command
  2284. line or via @option{-T} option.
  2285. This option instructs @command{tar} to process only the @var{number}th
  2286. occurrence of each named file. @var{Number} defaults to 1, so
  2287. @smallexample
  2288. tar -x -f archive.tar --occurrence filename
  2289. @end smallexample
  2290. @noindent
  2291. will extract the first occurrence of the member @file{filename} from @file{archive.tar}
  2292. and will terminate without scanning to the end of the archive.
  2293. @opsummary{old-archive}
  2294. @item --old-archive
  2295. Synonym for @option{--format=v7}.
  2296. @opsummary{one-file-system}
  2297. @item --one-file-system
  2298. Used when creating an archive. Prevents @command{tar} from recursing into
  2299. directories that are on different file systems from the current
  2300. directory @footnote{Earlier versions of @GNUTAR{} understood @option{-l} as a
  2301. synonym for @option{--one-file-system}. This has changed in version
  2302. 1.15.91. @xref{Changes}, for more information.}.
  2303. @opsummary{overwrite}
  2304. @item --overwrite
  2305. Overwrite existing files and directory metadata when extracting files
  2306. from an archive. @xref{Overwrite Old Files}.
  2307. @opsummary{overwrite-dir}
  2308. @item --overwrite-dir
  2309. Overwrite the metadata of existing directories when extracting files
  2310. from an archive. @xref{Overwrite Old Files}.
  2311. @opsummary{owner}
  2312. @item --owner=@var{user}
  2313. Specifies that @command{tar} should use @var{user} as the owner of members
  2314. when creating archives, instead of the user associated with the source
  2315. file. @var{user} is first decoded as a user symbolic name, but if
  2316. this interpretation fails, it has to be a decimal numeric user @acronym{ID}.
  2317. @xref{override}.
  2318. This option does not affect extraction from archives.
  2319. @opsummary{pax-option}
  2320. @item --pax-option=@var{keyword-list}
  2321. This option is meaningful only with @acronym{POSIX.1-2001} archives
  2322. (@pxref{posix}). It modifies the way @command{tar} handles the
  2323. extended header keywords. @var{Keyword-list} is a comma-separated
  2324. list of keyword options. @xref{PAX keywords}, for a detailed
  2325. discussion.
  2326. @opsummary{portability}
  2327. @item --portability
  2328. @itemx --old-archive
  2329. Synonym for @option{--format=v7}.
  2330. @opsummary{posix}
  2331. @item --posix
  2332. Same as @option{--format=posix}.
  2333. @opsummary{preserve}
  2334. @item --preserve
  2335. Synonymous with specifying both @option{--preserve-permissions} and
  2336. @option{--same-order}. @xref{Setting Access Permissions}.
  2337. @opsummary{preserve-order}
  2338. @item --preserve-order
  2339. (See @option{--same-order}; @pxref{Reading}.)
  2340. @opsummary{preserve-permissions}
  2341. @opsummary{same-permissions}
  2342. @item --preserve-permissions
  2343. @itemx --same-permissions
  2344. @itemx -p
  2345. When @command{tar} is extracting an archive, it normally subtracts the
  2346. users' umask from the permissions specified in the archive and uses
  2347. that number as the permissions to create the destination file.
  2348. Specifying this option instructs @command{tar} that it should use the
  2349. permissions directly from the archive. @xref{Setting Access Permissions}.
  2350. @opsummary{quote-chars}
  2351. @item --quote-chars=@var{string}
  2352. Always quote characters from @var{string}, even if the selected
  2353. quoting style would not quote them (@pxref{quoting styles}).
  2354. @opsummary{quoting-style}
  2355. @item --quoting-style=@var{style}
  2356. Set quoting style to use when printing member and file names
  2357. (@pxref{quoting styles}). Valid @var{style} values are:
  2358. @code{literal}, @code{shell}, @code{shell-always}, @code{c},
  2359. @code{escape}, @code{locale}, and @code{clocale}. Default quoting
  2360. style is @code{escape}, unless overridden while configuring the
  2361. package.
  2362. @opsummary{read-full-records}
  2363. @item --read-full-records
  2364. @itemx -B
  2365. Specifies that @command{tar} should reblock its input, for reading
  2366. from pipes on systems with buggy implementations. @xref{Reading}.
  2367. @opsummary{record-size}
  2368. @item --record-size=@var{size}
  2369. Instructs @command{tar} to use @var{size} bytes per record when accessing the
  2370. archive. @xref{Blocking Factor}.
  2371. @opsummary{recursion}
  2372. @item --recursion
  2373. With this option, @command{tar} recurses into directories (default).
  2374. @xref{recurse}.
  2375. @opsummary{recursive-unlink}
  2376. @item --recursive-unlink
  2377. Remove existing
  2378. directory hierarchies before extracting directories of the same name
  2379. from the archive. @xref{Recursive Unlink}.
  2380. @opsummary{remove-files}
  2381. @item --remove-files
  2382. Directs @command{tar} to remove the source file from the file system after
  2383. appending it to an archive. @xref{remove files}.
  2384. @opsummary{restrict}
  2385. @item --restrict
  2386. Disable use of some potentially harmful @command{tar} options.
  2387. Currently this option disables shell invocation from multi-volume menu
  2388. (@pxref{Using Multiple Tapes}).
  2389. @opsummary{rmt-command}
  2390. @item --rmt-command=@var{cmd}
  2391. Notifies @command{tar} that it should use @var{cmd} instead of
  2392. the default @file{/usr/libexec/rmt} (@pxref{Remote Tape Server}).
  2393. @opsummary{rsh-command}
  2394. @item --rsh-command=@var{cmd}
  2395. Notifies @command{tar} that is should use @var{cmd} to communicate with remote
  2396. devices. @xref{Device}.
  2397. @opsummary{same-order}
  2398. @item --same-order
  2399. @itemx --preserve-order
  2400. @itemx -s
  2401. This option is an optimization for @command{tar} when running on machines with
  2402. small amounts of memory. It informs @command{tar} that the list of file
  2403. arguments has already been sorted to match the order of files in the
  2404. archive. @xref{Reading}.
  2405. @opsummary{same-owner}
  2406. @item --same-owner
  2407. When extracting an archive, @command{tar} will attempt to preserve the owner
  2408. specified in the @command{tar} archive with this option present.
  2409. This is the default behavior for the superuser; this option has an
  2410. effect only for ordinary users. @xref{Attributes}.
  2411. @opsummary{same-permissions}
  2412. @item --same-permissions
  2413. (See @option{--preserve-permissions}; @pxref{Setting Access Permissions}.)
  2414. @opsummary{seek}
  2415. @item --seek
  2416. @itemx -n
  2417. Assume that the archive media supports seeks to arbitrary
  2418. locations. Usually @command{tar} determines automatically whether
  2419. the archive can be seeked or not. This option is intended for use
  2420. in cases when such recognition fails.
  2421. @opsummary{show-defaults}
  2422. @item --show-defaults
  2423. Displays the default options used by @command{tar} and exits
  2424. successfully. This option is intended for use in shell scripts.
  2425. Here is an example of what you can see using this option:
  2426. @smallexample
  2427. $ tar --show-defaults
  2428. --format=gnu -f- -b20 --quoting-style=escape \
  2429. --rmt-command=/usr/libexec/rmt --rsh-command=/usr/bin/rsh
  2430. @end smallexample
  2431. @opsummary{show-omitted-dirs}
  2432. @item --show-omitted-dirs
  2433. Instructs @command{tar} to mention the directories it is skipping when
  2434. operating on a @command{tar} archive. @xref{show-omitted-dirs}.
  2435. @opsummary{show-transformed-names}
  2436. @opsummary{show-stored-names}
  2437. @item --show-transformed-names
  2438. @itemx --show-stored-names
  2439. Display file or member names after applying any transformations
  2440. (@pxref{transform}). In particular, when used in conjunction with one of
  2441. the archive creation operations it instructs @command{tar} to list the
  2442. member names stored in the archive, as opposed to the actual file
  2443. names. @xref{listing member and file names}.
  2444. @opsummary{sparse}
  2445. @item --sparse
  2446. @itemx -S
  2447. Invokes a @acronym{GNU} extension when adding files to an archive that handles
  2448. sparse files efficiently. @xref{sparse}.
  2449. @opsummary{sparse-version}
  2450. @item --sparse-version=@var{version}
  2451. Specifies the @dfn{format version} to use when archiving sparse
  2452. files. Implies @option{--sparse}. @xref{sparse}. For the description
  2453. of the supported sparse formats, @xref{Sparse Formats}.
  2454. @opsummary{starting-file}
  2455. @item --starting-file=@var{name}
  2456. @itemx -K @var{name}
  2457. This option affects extraction only; @command{tar} will skip extracting
  2458. files in the archive until it finds one that matches @var{name}.
  2459. @xref{Scarce}.
  2460. @opsummary{strip-components}
  2461. @item --strip-components=@var{number}
  2462. Strip given @var{number} of leading components from file names before
  2463. extraction. For example, if archive @file{archive.tar} contained
  2464. @file{/some/file/name}, then running
  2465. @smallexample
  2466. tar --extract --file archive.tar --strip-components=2
  2467. @end smallexample
  2468. @noindent
  2469. would extract this file to file @file{name}.
  2470. @opsummary{suffix}, summary
  2471. @item --suffix=@var{suffix}
  2472. Alters the suffix @command{tar} uses when backing up files from the default
  2473. @samp{~}. @xref{backup}.
  2474. @opsummary{tape-length}
  2475. @item --tape-length=@var{num}
  2476. @itemx -L @var{num}
  2477. Specifies the length of tapes that @command{tar} is writing as being
  2478. @w{@var{num} x 1024} bytes long. @xref{Using Multiple Tapes}.
  2479. @opsummary{test-label}
  2480. @item --test-label
  2481. Reads the volume label. If an argument is specified, test whether it
  2482. matches the volume label. @xref{--test-label option}.
  2483. @opsummary{to-command}
  2484. @item --to-command=@var{command}
  2485. During extraction @command{tar} will pipe extracted files to the
  2486. standard input of @var{command}. @xref{Writing to an External Program}.
  2487. @opsummary{to-stdout}
  2488. @item --to-stdout
  2489. @itemx -O
  2490. During extraction, @command{tar} will extract files to stdout rather
  2491. than to the file system. @xref{Writing to Standard Output}.
  2492. @opsummary{totals}
  2493. @item --totals[=@var{signo}]
  2494. Displays the total number of bytes transferred when processing an
  2495. archive. If an argument is given, these data are displayed on
  2496. request, when signal @var{signo} is delivered to @command{tar}.
  2497. @xref{totals}.
  2498. @opsummary{touch}
  2499. @item --touch
  2500. @itemx -m
  2501. Sets the data modification time of extracted files to the extraction time,
  2502. rather than the data modification time stored in the archive.
  2503. @xref{Data Modification Times}.
  2504. @opsummary{transform}
  2505. @item --transform=@var{sed-expr}
  2506. Transform file or member names using @command{sed} replacement expression
  2507. @var{sed-expr}. For example,
  2508. @smallexample
  2509. $ @kbd{tar cf archive.tar --transform 's,^\./,usr/,' .}
  2510. @end smallexample
  2511. @noindent
  2512. will add to @file{archive} files from the current working directory,
  2513. replacing initial @samp{./} prefix with @samp{usr/}. For the detailed
  2514. discussion, @xref{transform}.
  2515. To see transformed member names in verbose listings, use
  2516. @option{--show-transformed-names} option
  2517. (@pxref{show-transformed-names}).
  2518. @opsummary{uncompress}
  2519. @item --uncompress
  2520. (See @option{--compress}. @pxref{gzip})
  2521. @opsummary{ungzip}
  2522. @item --ungzip
  2523. (See @option{--gzip}. @pxref{gzip})
  2524. @opsummary{unlink-first}
  2525. @item --unlink-first
  2526. @itemx -U
  2527. Directs @command{tar} to remove the corresponding file from the file
  2528. system before extracting it from the archive. @xref{Unlink First}.
  2529. @opsummary{unquote}
  2530. @item --unquote
  2531. Enable unquoting input file or member names (default). @xref{input
  2532. name quoting}.
  2533. @opsummary{use-compress-program}
  2534. @item --use-compress-program=@var{prog}
  2535. Instructs @command{tar} to access the archive through @var{prog}, which is
  2536. presumed to be a compression program of some sort. @xref{gzip}.
  2537. @opsummary{utc}
  2538. @item --utc
  2539. Display file modification dates in @acronym{UTC}. This option implies
  2540. @option{--verbose}.
  2541. @opsummary{verbose}
  2542. @item --verbose
  2543. @itemx -v
  2544. Specifies that @command{tar} should be more verbose about the
  2545. operations it is performing. This option can be specified multiple
  2546. times for some operations to increase the amount of information displayed.
  2547. @xref{verbose}.
  2548. @opsummary{verify}
  2549. @item --verify
  2550. @itemx -W
  2551. Verifies that the archive was correctly written when creating an
  2552. archive. @xref{verify}.
  2553. @opsummary{version}
  2554. @item --version
  2555. Print information about the program's name, version, origin and legal
  2556. status, all on standard output, and then exit successfully.
  2557. @xref{help}.
  2558. @opsummary{volno-file}
  2559. @item --volno-file=@var{file}
  2560. Used in conjunction with @option{--multi-volume}. @command{tar} will
  2561. keep track of which volume of a multi-volume archive it is working in
  2562. @var{file}. @xref{volno-file}.
  2563. @opsummary{wildcards}
  2564. @item --wildcards
  2565. Use wildcards when matching member names with patterns.
  2566. @xref{controlling pattern-matching}.
  2567. @opsummary{wildcards-match-slash}
  2568. @item --wildcards-match-slash
  2569. Wildcards match @samp{/}.
  2570. @xref{controlling pattern-matching}.
  2571. @end table
  2572. @node Short Option Summary
  2573. @subsection Short Options Cross Reference
  2574. Here is an alphabetized list of all of the short option forms, matching
  2575. them with the equivalent long option.
  2576. @multitable @columnfractions 0.20 0.80
  2577. @headitem Short Option @tab Reference
  2578. @item -A @tab @ref{--concatenate}.
  2579. @item -B @tab @ref{--read-full-records}.
  2580. @item -C @tab @ref{--directory}.
  2581. @item -F @tab @ref{--info-script}.
  2582. @item -G @tab @ref{--incremental}.
  2583. @item -K @tab @ref{--starting-file}.
  2584. @item -L @tab @ref{--tape-length}.
  2585. @item -M @tab @ref{--multi-volume}.
  2586. @item -N @tab @ref{--newer}.
  2587. @item -O @tab @ref{--to-stdout}.
  2588. @item -P @tab @ref{--absolute-names}.
  2589. @item -R @tab @ref{--block-number}.
  2590. @item -S @tab @ref{--sparse}.
  2591. @item -T @tab @ref{--files-from}.
  2592. @item -U @tab @ref{--unlink-first}.
  2593. @item -V @tab @ref{--label}.
  2594. @item -W @tab @ref{--verify}.
  2595. @item -X @tab @ref{--exclude-from}.
  2596. @item -Z @tab @ref{--compress}.
  2597. @item -b @tab @ref{--blocking-factor}.
  2598. @item -c @tab @ref{--create}.
  2599. @item -d @tab @ref{--compare}.
  2600. @item -f @tab @ref{--file}.
  2601. @item -g @tab @ref{--listed-incremental}.
  2602. @item -h @tab @ref{--dereference}.
  2603. @item -i @tab @ref{--ignore-zeros}.
  2604. @item -j @tab @ref{--bzip2}.
  2605. @item -k @tab @ref{--keep-old-files}.
  2606. @item -l @tab @ref{--check-links}.
  2607. @item -m @tab @ref{--touch}.
  2608. @item -o @tab When creating, @ref{--no-same-owner}, when extracting ---
  2609. @ref{--portability}.
  2610. The later usage is deprecated. It is retained for compatibility with
  2611. the earlier versions of @GNUTAR{}. In future releases
  2612. @option{-o} will be equivalent to @option{--no-same-owner} only.
  2613. @item -p @tab @ref{--preserve-permissions}.
  2614. @item -r @tab @ref{--append}.
  2615. @item -s @tab @ref{--same-order}.
  2616. @item -t @tab @ref{--list}.
  2617. @item -u @tab @ref{--update}.
  2618. @item -v @tab @ref{--verbose}.
  2619. @item -w @tab @ref{--interactive}.
  2620. @item -x @tab @ref{--extract}.
  2621. @item -z @tab @ref{--gzip}.
  2622. @end multitable
  2623. @node help
  2624. @section @GNUTAR{} documentation
  2625. @cindex Getting program version number
  2626. @opindex version
  2627. @cindex Version of the @command{tar} program
  2628. Being careful, the first thing is really checking that you are using
  2629. @GNUTAR{}, indeed. The @option{--version} option
  2630. causes @command{tar} to print information about its name, version,
  2631. origin and legal status, all on standard output, and then exit
  2632. successfully. For example, @w{@samp{tar --version}} might print:
  2633. @smallexample
  2634. tar (GNU tar) @value{VERSION}
  2635. Copyright (C) 2006 Free Software Foundation, Inc.
  2636. This is free software. You may redistribute copies of it under the terms
  2637. of the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
  2638. There is NO WARRANTY, to the extent permitted by law.
  2639. Written by John Gilmore and Jay Fenlason.
  2640. @end smallexample
  2641. @noindent
  2642. The first occurrence of @samp{tar} in the result above is the program
  2643. name in the package (for example, @command{rmt} is another program),
  2644. while the second occurrence of @samp{tar} is the name of the package
  2645. itself, containing possibly many programs. The package is currently
  2646. named @samp{tar}, after the name of the main program it
  2647. contains@footnote{There are plans to merge the @command{cpio} and
  2648. @command{tar} packages into a single one which would be called
  2649. @code{paxutils}. So, who knows if, one of this days, the
  2650. @option{--version} would not output @w{@samp{tar (@acronym{GNU}
  2651. paxutils) 3.2}}}.
  2652. @cindex Obtaining help
  2653. @cindex Listing all @command{tar} options
  2654. @xopindex{help, introduction}
  2655. Another thing you might want to do is checking the spelling or meaning
  2656. of some particular @command{tar} option, without resorting to this
  2657. manual, for once you have carefully read it. @GNUTAR{}
  2658. has a short help feature, triggerable through the
  2659. @option{--help} option. By using this option, @command{tar} will
  2660. print a usage message listing all available options on standard
  2661. output, then exit successfully, without doing anything else and
  2662. ignoring all other options. Even if this is only a brief summary, it
  2663. may be several screens long. So, if you are not using some kind of
  2664. scrollable window, you might prefer to use something like:
  2665. @smallexample
  2666. $ @kbd{tar --help | less}
  2667. @end smallexample
  2668. @noindent
  2669. presuming, here, that you like using @command{less} for a pager. Other
  2670. popular pagers are @command{more} and @command{pg}. If you know about some
  2671. @var{keyword} which interests you and do not want to read all the
  2672. @option{--help} output, another common idiom is doing:
  2673. @smallexample
  2674. tar --help | grep @var{keyword}
  2675. @end smallexample
  2676. @noindent
  2677. for getting only the pertinent lines. Notice, however, that some
  2678. @command{tar} options have long description lines and the above
  2679. command will list only the first of them.
  2680. The exact look of the option summary displayed by @kbd{tar --help} is
  2681. configurable. @xref{Configuring Help Summary}, for a detailed description.
  2682. @opindex usage
  2683. If you only wish to check the spelling of an option, running @kbd{tar
  2684. --usage} may be a better choice. This will display a terse list of
  2685. @command{tar} option without accompanying explanations.
  2686. The short help output is quite succinct, and you might have to get
  2687. back to the full documentation for precise points. If you are reading
  2688. this paragraph, you already have the @command{tar} manual in some
  2689. form. This manual is available in a variety of forms from
  2690. @url{http://www.gnu.org/software/tar/manual}. It may be printed out of the @GNUTAR{}
  2691. distribution, provided you have @TeX{} already installed somewhere,
  2692. and a laser printer around. Just configure the distribution, execute
  2693. the command @w{@samp{make dvi}}, then print @file{doc/tar.dvi} the
  2694. usual way (contact your local guru to know how). If @GNUTAR{}
  2695. has been conveniently installed at your place, this
  2696. manual is also available in interactive, hypertextual form as an Info
  2697. file. Just call @w{@samp{info tar}} or, if you do not have the
  2698. @command{info} program handy, use the Info reader provided within
  2699. @acronym{GNU} Emacs, calling @samp{tar} from the main Info menu.
  2700. There is currently no @code{man} page for @GNUTAR{}.
  2701. If you observe such a @code{man} page on the system you are running,
  2702. either it does not belong to @GNUTAR{}, or it has not
  2703. been produced by @acronym{GNU}. Some package maintainers convert
  2704. @kbd{tar --help} output to a man page, using @command{help2man}. In
  2705. any case, please bear in mind that the authoritative source of
  2706. information about @GNUTAR{} is this Texinfo documentation.
  2707. @node defaults
  2708. @section Obtaining @GNUTAR{} default values
  2709. @opindex show-defaults
  2710. @GNUTAR{} has some predefined defaults that are used when you do not
  2711. explicitly specify another values. To obtain a list of such
  2712. defaults, use @option{--show-defaults} option. This will output the
  2713. values in the form of @command{tar} command line options:
  2714. @smallexample
  2715. @group
  2716. @kbd{tar --show-defaults}
  2717. --format=gnu -f- -b20 --quoting-style=escape
  2718. --rmt-command=/etc/rmt --rsh-command=/usr/bin/rsh
  2719. @end group
  2720. @end smallexample
  2721. @noindent
  2722. Notice, that this option outputs only one line. The example output above
  2723. has been split to fit page boundaries.
  2724. @noindent
  2725. The above output shows that this version of @GNUTAR{} defaults to
  2726. using @samp{gnu} archive format (@pxref{Formats}), it uses standard
  2727. output as the archive, if no @option{--file} option has been given
  2728. (@pxref{file tutorial}), the default blocking factor is 20
  2729. (@pxref{Blocking Factor}). It also shows the default locations where
  2730. @command{tar} will look for @command{rmt} and @command{rsh} binaries.
  2731. @node verbose
  2732. @section Checking @command{tar} progress
  2733. Typically, @command{tar} performs most operations without reporting any
  2734. information to the user except error messages. When using @command{tar}
  2735. with many options, particularly ones with complicated or
  2736. difficult-to-predict behavior, it is possible to make serious mistakes.
  2737. @command{tar} provides several options that make observing @command{tar}
  2738. easier. These options cause @command{tar} to print information as it
  2739. progresses in its job, and you might want to use them just for being
  2740. more careful about what is going on, or merely for entertaining
  2741. yourself. If you have encountered a problem when operating on an
  2742. archive, however, you may need more information than just an error
  2743. message in order to solve the problem. The following options can be
  2744. helpful diagnostic tools.
  2745. @cindex Verbose operation
  2746. @opindex verbose
  2747. Normally, the @option{--list} (@option{-t}) command to list an archive
  2748. prints just the file names (one per line) and the other commands are
  2749. silent. When used with most operations, the @option{--verbose}
  2750. (@option{-v}) option causes @command{tar} to print the name of each
  2751. file or archive member as it is processed. This and the other options
  2752. which make @command{tar} print status information can be useful in
  2753. monitoring @command{tar}.
  2754. With @option{--create} or @option{--extract}, @option{--verbose} used
  2755. once just prints the names of the files or members as they are processed.
  2756. Using it twice causes @command{tar} to print a longer listing
  2757. (@xref{verbose member listing}, for the description) for each member.
  2758. Since @option{--list} already prints the names of the members,
  2759. @option{--verbose} used once with @option{--list} causes @command{tar}
  2760. to print an @samp{ls -l} type listing of the files in the archive.
  2761. The following examples both extract members with long list output:
  2762. @smallexample
  2763. $ @kbd{tar --extract --file=archive.tar --verbose --verbose}
  2764. $ @kbd{tar xvvf archive.tar}
  2765. @end smallexample
  2766. Verbose output appears on the standard output except when an archive is
  2767. being written to the standard output, as with @samp{tar --create
  2768. --file=- --verbose} (@samp{tar cfv -}, or even @samp{tar cv}---if the
  2769. installer let standard output be the default archive). In that case
  2770. @command{tar} writes verbose output to the standard error stream.
  2771. If @option{--index-file=@var{file}} is specified, @command{tar} sends
  2772. verbose output to @var{file} rather than to standard output or standard
  2773. error.
  2774. @anchor{totals}
  2775. @cindex Obtaining total status information
  2776. @opindex totals
  2777. The @option{--totals} option causes @command{tar} to print on the
  2778. standard error the total amount of bytes transferred when processing
  2779. an archive. When creating or appending to an archive, this option
  2780. prints the number of bytes written to the archive and the average
  2781. speed at which they have been written, e.g.:
  2782. @smallexample
  2783. @group
  2784. $ @kbd{tar -c -f archive.tar --totals /home}
  2785. Total bytes written: 7924664320 (7.4GiB, 85MiB/s)
  2786. @end group
  2787. @end smallexample
  2788. When reading an archive, this option displays the number of bytes
  2789. read:
  2790. @smallexample
  2791. @group
  2792. $ @kbd{tar -x -f archive.tar --totals}
  2793. Total bytes read: 7924664320 (7.4GiB, 95MiB/s)
  2794. @end group
  2795. @end smallexample
  2796. Finally, when deleting from an archive, the @option{--totals} option
  2797. displays both numbers plus number of bytes removed from the archive:
  2798. @smallexample
  2799. @group
  2800. $ @kbd{tar --delete -f foo.tar --totals --wildcards '*~'}
  2801. Total bytes read: 9543680 (9.2MiB, 201MiB/s)
  2802. Total bytes written: 3829760 (3.7MiB, 81MiB/s)
  2803. Total bytes deleted: 1474048
  2804. @end group
  2805. @end smallexample
  2806. You can also obtain this information on request. When
  2807. @option{--totals} is used with an argument, this argument is
  2808. interpreted as a symbolic name of a signal, upon delivery of which the
  2809. statistics is to be printed:
  2810. @table @option
  2811. @item --totals=@var{signo}
  2812. Print statistics upon delivery of signal @var{signo}. Valid arguments
  2813. are: @code{SIGHUP}, @code{SIGQUIT}, @code{SIGINT}, @code{SIGUSR1} and
  2814. @code{SIGUSR2}. Shortened names without @samp{SIG} prefix are also
  2815. accepted.
  2816. @end table
  2817. Both forms of @option{--totals} option can be used simultaneously.
  2818. Thus, @kbd{tar -x --totals --totals=USR1} instructs @command{tar} to
  2819. extract all members from its default archive and print statistics
  2820. after finishing the extraction, as well as when receiving signal
  2821. @code{SIGUSR1}.
  2822. @anchor{Progress information}
  2823. @cindex Progress information
  2824. @opindex checkpoint
  2825. The @option{--checkpoint} option prints an occasional message
  2826. as @command{tar} reads or writes the archive. It is designed for
  2827. those who don't need the more detailed (and voluminous) output of
  2828. @option{--block-number} (@option{-R}), but do want visual confirmation
  2829. that @command{tar} is actually making forward progress. By default it
  2830. prints a message each 10 records read or written. This can be changed
  2831. by giving it a numeric argument after an equal sign:
  2832. @smallexample
  2833. $ @kbd{tar -c --checkpoint=1000} /var
  2834. tar: Write checkpoint 1000
  2835. tar: Write checkpoint 2000
  2836. tar: Write checkpoint 3000
  2837. @end smallexample
  2838. This example shows the default checkpoint message used by
  2839. @command{tar}. If you place a dot immediately after the equal
  2840. sign, it will print a @samp{.} at each checkpoint. For example:
  2841. @smallexample
  2842. $ @kbd{tar -c --checkpoint=.1000} /var
  2843. ...
  2844. @end smallexample
  2845. @opindex show-omitted-dirs
  2846. @anchor{show-omitted-dirs}
  2847. The @option{--show-omitted-dirs} option, when reading an archive---with
  2848. @option{--list} or @option{--extract}, for example---causes a message
  2849. to be printed for each directory in the archive which is skipped.
  2850. This happens regardless of the reason for skipping: the directory might
  2851. not have been named on the command line (implicitly or explicitly),
  2852. it might be excluded by the use of the
  2853. @option{--exclude=@var{pattern}} option, or some other reason.
  2854. @opindex block-number
  2855. @cindex Block number where error occurred
  2856. @anchor{block-number}
  2857. If @option{--block-number} (@option{-R}) is used, @command{tar} prints, along with
  2858. every message it would normally produce, the block number within the
  2859. archive where the message was triggered. Also, supplementary messages
  2860. are triggered when reading blocks full of NULs, or when hitting end of
  2861. file on the archive. As of now, if the archive if properly terminated
  2862. with a NUL block, the reading of the file may stop before end of file
  2863. is met, so the position of end of file will not usually show when
  2864. @option{--block-number} (@option{-R}) is used. Note that @GNUTAR{}
  2865. drains the archive before exiting when reading the
  2866. archive from a pipe.
  2867. @cindex Error message, block number of
  2868. This option is especially useful when reading damaged archives, since
  2869. it helps pinpoint the damaged sections. It can also be used with
  2870. @option{--list} (@option{-t}) when listing a file-system backup tape, allowing you to
  2871. choose among several backup tapes when retrieving a file later, in
  2872. favor of the tape where the file appears earliest (closest to the
  2873. front of the tape). @xref{backup}.
  2874. @node interactive
  2875. @section Asking for Confirmation During Operations
  2876. @cindex Interactive operation
  2877. Typically, @command{tar} carries out a command without stopping for
  2878. further instructions. In some situations however, you may want to
  2879. exclude some files and archive members from the operation (for instance
  2880. if disk or storage space is tight). You can do this by excluding
  2881. certain files automatically (@pxref{Choosing}), or by performing
  2882. an operation interactively, using the @option{--interactive} (@option{-w}) option.
  2883. @command{tar} also accepts @option{--confirmation} for this option.
  2884. @opindex interactive
  2885. When the @option{--interactive} (@option{-w}) option is specified, before
  2886. reading, writing, or deleting files, @command{tar} first prints a message
  2887. for each such file, telling what operation it intends to take, then asks
  2888. for confirmation on the terminal. The actions which require
  2889. confirmation include adding a file to the archive, extracting a file
  2890. from the archive, deleting a file from the archive, and deleting a file
  2891. from disk. To confirm the action, you must type a line of input
  2892. beginning with @samp{y}. If your input line begins with anything other
  2893. than @samp{y}, @command{tar} skips that file.
  2894. If @command{tar} is reading the archive from the standard input,
  2895. @command{tar} opens the file @file{/dev/tty} to support the interactive
  2896. communications.
  2897. Verbose output is normally sent to standard output, separate from
  2898. other error messages. However, if the archive is produced directly
  2899. on standard output, then verbose output is mixed with errors on
  2900. @code{stderr}. Producing the archive on standard output may be used
  2901. as a way to avoid using disk space, when the archive is soon to be
  2902. consumed by another process reading it, say. Some people felt the need
  2903. of producing an archive on stdout, still willing to segregate between
  2904. verbose output and error output. A possible approach would be using a
  2905. named pipe to receive the archive, and having the consumer process to
  2906. read from that named pipe. This has the advantage of letting standard
  2907. output free to receive verbose output, all separate from errors.
  2908. @node operations
  2909. @chapter @GNUTAR{} Operations
  2910. @menu
  2911. * Basic tar::
  2912. * Advanced tar::
  2913. * create options::
  2914. * extract options::
  2915. * backup::
  2916. * Applications::
  2917. * looking ahead::
  2918. @end menu
  2919. @node Basic tar
  2920. @section Basic @GNUTAR{} Operations
  2921. The basic @command{tar} operations, @option{--create} (@option{-c}),
  2922. @option{--list} (@option{-t}) and @option{--extract} (@option{--get},
  2923. @option{-x}), are currently presented and described in the tutorial
  2924. chapter of this manual. This section provides some complementary notes
  2925. for these operations.
  2926. @table @option
  2927. @xopindex{create, complementary notes}
  2928. @item --create
  2929. @itemx -c
  2930. Creating an empty archive would have some kind of elegance. One can
  2931. initialize an empty archive and later use @option{--append}
  2932. (@option{-r}) for adding all members. Some applications would not
  2933. welcome making an exception in the way of adding the first archive
  2934. member. On the other hand, many people reported that it is
  2935. dangerously too easy for @command{tar} to destroy a magnetic tape with
  2936. an empty archive@footnote{This is well described in @cite{Unix-haters
  2937. Handbook}, by Simson Garfinkel, Daniel Weise & Steven Strassmann, IDG
  2938. Books, ISBN 1-56884-203-1.}. The two most common errors are:
  2939. @enumerate
  2940. @item
  2941. Mistakingly using @code{create} instead of @code{extract}, when the
  2942. intent was to extract the full contents of an archive. This error
  2943. is likely: keys @kbd{c} and @kbd{x} are right next to each other on
  2944. the QWERTY keyboard. Instead of being unpacked, the archive then
  2945. gets wholly destroyed. When users speak about @dfn{exploding} an
  2946. archive, they usually mean something else :-).
  2947. @item
  2948. Forgetting the argument to @code{file}, when the intent was to create
  2949. an archive with a single file in it. This error is likely because a
  2950. tired user can easily add the @kbd{f} key to the cluster of option
  2951. letters, by the mere force of habit, without realizing the full
  2952. consequence of doing so. The usual consequence is that the single
  2953. file, which was meant to be saved, is rather destroyed.
  2954. @end enumerate
  2955. So, recognizing the likelihood and the catastrophic nature of these
  2956. errors, @GNUTAR{} now takes some distance from elegance, and
  2957. cowardly refuses to create an archive when @option{--create} option is
  2958. given, there are no arguments besides options, and
  2959. @option{--files-from} (@option{-T}) option is @emph{not} used. To get
  2960. around the cautiousness of @GNUTAR{} and nevertheless create an
  2961. archive with nothing in it, one may still use, as the value for the
  2962. @option{--files-from} option, a file with no names in it, as shown in
  2963. the following commands:
  2964. @smallexample
  2965. @kbd{tar --create --file=empty-archive.tar --files-from=/dev/null}
  2966. @kbd{tar cfT empty-archive.tar /dev/null}
  2967. @end smallexample
  2968. @xopindex{extract, complementary notes}
  2969. @item --extract
  2970. @itemx --get
  2971. @itemx -x
  2972. A socket is stored, within a @GNUTAR{} archive, as a pipe.
  2973. @item @option{--list} (@option{-t})
  2974. @GNUTAR{} now shows dates as @samp{1996-08-30},
  2975. while it used to show them as @samp{Aug 30 1996}. Preferably,
  2976. people should get used to ISO 8601 dates. Local American dates should
  2977. be made available again with full date localization support, once
  2978. ready. In the meantime, programs not being localizable for dates
  2979. should prefer international dates, that's really the way to go.
  2980. Look up @url{http://www.cl.cam.ac.uk/@/~mgk25/@/iso-time.html} if you
  2981. are curious, it contains a detailed explanation of the ISO 8601 standard.
  2982. @end table
  2983. @node Advanced tar
  2984. @section Advanced @GNUTAR{} Operations
  2985. Now that you have learned the basics of using @GNUTAR{}, you may want
  2986. to learn about further ways in which @command{tar} can help you.
  2987. This chapter presents five, more advanced operations which you probably
  2988. won't use on a daily basis, but which serve more specialized functions.
  2989. We also explain the different styles of options and why you might want
  2990. to use one or another, or a combination of them in your @command{tar}
  2991. commands. Additionally, this chapter includes options which allow you to
  2992. define the output from @command{tar} more carefully, and provide help and
  2993. error correction in special circumstances.
  2994. @FIXME{check this after the chapter is actually revised to make sure
  2995. it still introduces the info in the chapter correctly : ).}
  2996. @menu
  2997. * Operations::
  2998. * append::
  2999. * update::
  3000. * concatenate::
  3001. * delete::
  3002. * compare::
  3003. @end menu
  3004. @node Operations
  3005. @subsection The Five Advanced @command{tar} Operations
  3006. @UNREVISED
  3007. In the last chapter, you learned about the first three operations to
  3008. @command{tar}. This chapter presents the remaining five operations to
  3009. @command{tar}: @option{--append}, @option{--update}, @option{--concatenate},
  3010. @option{--delete}, and @option{--compare}.
  3011. You are not likely to use these operations as frequently as those
  3012. covered in the last chapter; however, since they perform specialized
  3013. functions, they are quite useful when you do need to use them. We
  3014. will give examples using the same directory and files that you created
  3015. in the last chapter. As you may recall, the directory is called
  3016. @file{practice}, the files are @samp{jazz}, @samp{blues}, @samp{folk},
  3017. @samp{rock}, and the two archive files you created are
  3018. @samp{collection.tar} and @samp{music.tar}.
  3019. We will also use the archive files @samp{afiles.tar} and
  3020. @samp{bfiles.tar}. The archive @samp{afiles.tar} contains the members @samp{apple},
  3021. @samp{angst}, and @samp{aspic}; @samp{bfiles.tar} contains the members
  3022. @samp{./birds}, @samp{baboon}, and @samp{./box}.
  3023. Unless we state otherwise, all practicing you do and examples you follow
  3024. in this chapter will take place in the @file{practice} directory that
  3025. you created in the previous chapter; see @ref{prepare for examples}.
  3026. (Below in this section, we will remind you of the state of the examples
  3027. where the last chapter left them.)
  3028. The five operations that we will cover in this chapter are:
  3029. @table @option
  3030. @item --append
  3031. @itemx -r
  3032. Add new entries to an archive that already exists.
  3033. @item --update
  3034. @itemx -r
  3035. Add more recent copies of archive members to the end of an archive, if
  3036. they exist.
  3037. @item --concatenate
  3038. @itemx --catenate
  3039. @itemx -A
  3040. Add one or more pre-existing archives to the end of another archive.
  3041. @item --delete
  3042. Delete items from an archive (does not work on tapes).
  3043. @item --compare
  3044. @itemx --diff
  3045. @itemx -d
  3046. Compare archive members to their counterparts in the file system.
  3047. @end table
  3048. @node append
  3049. @subsection How to Add Files to Existing Archives: @option{--append}
  3050. @UNREVISED
  3051. @opindex append
  3052. If you want to add files to an existing archive, you don't need to
  3053. create a new archive; you can use @option{--append} (@option{-r}).
  3054. The archive must already exist in order to use @option{--append}. (A
  3055. related operation is the @option{--update} operation; you can use this
  3056. to add newer versions of archive members to an existing archive. To learn how to
  3057. do this with @option{--update}, @pxref{update}.)
  3058. If you use @option{--append} to add a file that has the same name as an
  3059. archive member to an archive containing that archive member, then the
  3060. old member is not deleted. What does happen, however, is somewhat
  3061. complex. @command{tar} @emph{allows} you to have infinite number of files
  3062. with the same name. Some operations treat these same-named members no
  3063. differently than any other set of archive members: for example, if you
  3064. view an archive with @option{--list} (@option{-t}), you will see all
  3065. of those members listed, with their data modification times, owners, etc.
  3066. Other operations don't deal with these members as perfectly as you might
  3067. prefer; if you were to use @option{--extract} to extract the archive,
  3068. only the most recently added copy of a member with the same name as four
  3069. other members would end up in the working directory. This is because
  3070. @option{--extract} extracts an archive in the order the members appeared
  3071. in the archive; the most recently archived members will be extracted
  3072. last. Additionally, an extracted member will @emph{replace} a file of
  3073. the same name which existed in the directory already, and @command{tar}
  3074. will not prompt you about this@footnote{Unless you give it
  3075. @option{--keep-old-files} option, or the disk copy is newer than the
  3076. the one in the archive and you invoke @command{tar} with
  3077. @option{--keep-newer-files} option}. Thus, only the most recently archived
  3078. member will end up being extracted, as it will replace the one
  3079. extracted before it, and so on.
  3080. There exists a special option that allows you to get around this
  3081. behavior and extract (or list) only a particular copy of the file.
  3082. This is @option{--occurrence} option. If you run @command{tar} with
  3083. this option, it will extract only the first copy of the file. You
  3084. may also give this option an argument specifying the number of
  3085. copy to be extracted. Thus, for example if the archive
  3086. @file{archive.tar} contained three copies of file @file{myfile}, then
  3087. the command
  3088. @smallexample
  3089. tar --extract --file archive.tar --occurrence=2 myfile
  3090. @end smallexample
  3091. @noindent
  3092. would extract only the second copy. @xref{Option
  3093. Summary,---occurrence}, for the description of @option{--occurrence}
  3094. option.
  3095. @FIXME{ hag -- you might want to incorporate some of the above into the
  3096. MMwtSN node; not sure. i didn't know how to make it simpler...
  3097. There are a few ways to get around this. (maybe xref Multiple Members
  3098. with the Same Name.}
  3099. @cindex Members, replacing with other members
  3100. @cindex Replacing members with other members
  3101. If you want to replace an archive member, use @option{--delete} to
  3102. delete the member you want to remove from the archive, , and then use
  3103. @option{--append} to add the member you want to be in the archive. Note
  3104. that you can not change the order of the archive; the most recently
  3105. added member will still appear last. In this sense, you cannot truly
  3106. ``replace'' one member with another. (Replacing one member with another
  3107. will not work on certain types of media, such as tapes; see @ref{delete}
  3108. and @ref{Media}, for more information.)
  3109. @menu
  3110. * appending files:: Appending Files to an Archive
  3111. * multiple::
  3112. @end menu
  3113. @node appending files
  3114. @subsubsection Appending Files to an Archive
  3115. @UNREVISED
  3116. @cindex Adding files to an Archive
  3117. @cindex Appending files to an Archive
  3118. @cindex Archives, Appending files to
  3119. The simplest way to add a file to an already existing archive is the
  3120. @option{--append} (@option{-r}) operation, which writes specified
  3121. files into the archive whether or not they are already among the
  3122. archived files.
  3123. When you use @option{--append}, you @emph{must} specify file name
  3124. arguments, as there is no default. If you specify a file that already
  3125. exists in the archive, another copy of the file will be added to the
  3126. end of the archive. As with other operations, the member names of the
  3127. newly added files will be exactly the same as their names given on the
  3128. command line. The @option{--verbose} (@option{-v}) option will print
  3129. out the names of the files as they are written into the archive.
  3130. @option{--append} cannot be performed on some tape drives, unfortunately,
  3131. due to deficiencies in the formats those tape drives use. The archive
  3132. must be a valid @command{tar} archive, or else the results of using this
  3133. operation will be unpredictable. @xref{Media}.
  3134. To demonstrate using @option{--append} to add a file to an archive,
  3135. create a file called @file{rock} in the @file{practice} directory.
  3136. Make sure you are in the @file{practice} directory. Then, run the
  3137. following @command{tar} command to add @file{rock} to
  3138. @file{collection.tar}:
  3139. @smallexample
  3140. $ @kbd{tar --append --file=collection.tar rock}
  3141. @end smallexample
  3142. @noindent
  3143. If you now use the @option{--list} (@option{-t}) operation, you will see that
  3144. @file{rock} has been added to the archive:
  3145. @smallexample
  3146. $ @kbd{tar --list --file=collection.tar}
  3147. -rw-r--r-- me user 28 1996-10-18 16:31 jazz
  3148. -rw-r--r-- me user 21 1996-09-23 16:44 blues
  3149. -rw-r--r-- me user 20 1996-09-23 16:44 folk
  3150. -rw-r--r-- me user 20 1996-09-23 16:44 rock
  3151. @end smallexample
  3152. @node multiple
  3153. @subsubsection Multiple Members with the Same Name
  3154. You can use @option{--append} (@option{-r}) to add copies of files
  3155. which have been updated since the archive was created. (However, we
  3156. do not recommend doing this since there is another @command{tar}
  3157. option called @option{--update}; @xref{update}, for more information.
  3158. We describe this use of @option{--append} here for the sake of
  3159. completeness.) When you extract the archive, the older version will
  3160. be effectively lost. This works because files are extracted from an
  3161. archive in the order in which they were archived. Thus, when the
  3162. archive is extracted, a file archived later in time will replace a
  3163. file of the same name which was archived earlier, even though the
  3164. older version of the file will remain in the archive unless you delete
  3165. all versions of the file.
  3166. Supposing you change the file @file{blues} and then append the changed
  3167. version to @file{collection.tar}. As you saw above, the original
  3168. @file{blues} is in the archive @file{collection.tar}. If you change the
  3169. file and append the new version of the file to the archive, there will
  3170. be two copies in the archive. When you extract the archive, the older
  3171. version of the file will be extracted first, and then replaced by the
  3172. newer version when it is extracted.
  3173. You can append the new, changed copy of the file @file{blues} to the
  3174. archive in this way:
  3175. @smallexample
  3176. $ @kbd{tar --append --verbose --file=collection.tar blues}
  3177. blues
  3178. @end smallexample
  3179. @noindent
  3180. Because you specified the @option{--verbose} option, @command{tar} has
  3181. printed the name of the file being appended as it was acted on. Now
  3182. list the contents of the archive:
  3183. @smallexample
  3184. $ @kbd{tar --list --verbose --file=collection.tar}
  3185. -rw-r--r-- me user 28 1996-10-18 16:31 jazz
  3186. -rw-r--r-- me user 21 1996-09-23 16:44 blues
  3187. -rw-r--r-- me user 20 1996-09-23 16:44 folk
  3188. -rw-r--r-- me user 20 1996-09-23 16:44 rock
  3189. -rw-r--r-- me user 58 1996-10-24 18:30 blues
  3190. @end smallexample
  3191. @noindent
  3192. The newest version of @file{blues} is now at the end of the archive
  3193. (note the different creation dates and file sizes). If you extract
  3194. the archive, the older version of the file @file{blues} will be
  3195. replaced by the newer version. You can confirm this by extracting
  3196. the archive and running @samp{ls} on the directory.
  3197. If you wish to extract the first occurrence of the file @file{blues}
  3198. from the archive, use @option{--occurrence} option, as shown in
  3199. the following example:
  3200. @smallexample
  3201. $ @kbd{tar --extract -vv --occurrence --file=collection.tar blues}
  3202. -rw-r--r-- me user 21 1996-09-23 16:44 blues
  3203. @end smallexample
  3204. @xref{Writing}, for more information on @option{--extract} and
  3205. @xref{Option Summary, --occurrence}, for the description of
  3206. @option{--occurrence} option.
  3207. @node update
  3208. @subsection Updating an Archive
  3209. @UNREVISED
  3210. @cindex Updating an archive
  3211. @opindex update
  3212. In the previous section, you learned how to use @option{--append} to
  3213. add a file to an existing archive. A related operation is
  3214. @option{--update} (@option{-u}). The @option{--update} operation
  3215. updates a @command{tar} archive by comparing the date of the specified
  3216. archive members against the date of the file with the same name. If
  3217. the file has been modified more recently than the archive member, then
  3218. the newer version of the file is added to the archive (as with
  3219. @option{--append}).
  3220. Unfortunately, you cannot use @option{--update} with magnetic tape drives.
  3221. The operation will fail.
  3222. @FIXME{other examples of media on which --update will fail? need to ask
  3223. charles and/or mib/thomas/dave shevett..}
  3224. Both @option{--update} and @option{--append} work by adding to the end
  3225. of the archive. When you extract a file from the archive, only the
  3226. version stored last will wind up in the file system, unless you use
  3227. the @option{--backup} option. @xref{multiple}, for a detailed discussion.
  3228. @menu
  3229. * how to update::
  3230. @end menu
  3231. @node how to update
  3232. @subsubsection How to Update an Archive Using @option{--update}
  3233. You must use file name arguments with the @option{--update}
  3234. (@option{-u}) operation. If you don't specify any files,
  3235. @command{tar} won't act on any files and won't tell you that it didn't
  3236. do anything (which may end up confusing you).
  3237. @c note: the above parenthetical added because in fact, this
  3238. @c behavior just confused the author. :-)
  3239. To see the @option{--update} option at work, create a new file,
  3240. @file{classical}, in your practice directory, and some extra text to the
  3241. file @file{blues}, using any text editor. Then invoke @command{tar} with
  3242. the @samp{update} operation and the @option{--verbose} (@option{-v})
  3243. option specified, using the names of all the files in the practice
  3244. directory as file name arguments:
  3245. @smallexample
  3246. $ @kbd{tar --update -v -f collection.tar blues folk rock classical}
  3247. blues
  3248. classical
  3249. $
  3250. @end smallexample
  3251. @noindent
  3252. Because we have specified verbose mode, @command{tar} prints out the names
  3253. of the files it is working on, which in this case are the names of the
  3254. files that needed to be updated. If you run @samp{tar --list} and look
  3255. at the archive, you will see @file{blues} and @file{classical} at its
  3256. end. There will be a total of two versions of the member @samp{blues};
  3257. the one at the end will be newer and larger, since you added text before
  3258. updating it.
  3259. (The reason @command{tar} does not overwrite the older file when updating
  3260. it is because writing to the middle of a section of tape is a difficult
  3261. process. Tapes are not designed to go backward. @xref{Media}, for more
  3262. information about tapes.
  3263. @option{--update} (@option{-u}) is not suitable for performing backups for two
  3264. reasons: it does not change directory content entries, and it
  3265. lengthens the archive every time it is used. The @GNUTAR{}
  3266. options intended specifically for backups are more
  3267. efficient. If you need to run backups, please consult @ref{Backups}.
  3268. @node concatenate
  3269. @subsection Combining Archives with @option{--concatenate}
  3270. @cindex Adding archives to an archive
  3271. @cindex Concatenating Archives
  3272. @opindex concatenate
  3273. @opindex catenate
  3274. @c @cindex @option{-A} described
  3275. Sometimes it may be convenient to add a second archive onto the end of
  3276. an archive rather than adding individual files to the archive. To add
  3277. one or more archives to the end of another archive, you should use the
  3278. @option{--concatenate} (@option{--catenate}, @option{-A}) operation.
  3279. To use @option{--concatenate}, give the first archive with
  3280. @option{--file} option and name the rest of archives to be
  3281. concatenated on the command line. The members, and their member
  3282. names, will be copied verbatim from those archives to the first one.
  3283. @footnote{This can cause multiple members to have the same name, for
  3284. information on how this affects reading the archive, @ref{multiple}.}
  3285. The new, concatenated archive will be called by the same name as the
  3286. one given with the @option{--file} option. As usual, if you omit
  3287. @option{--file}, @command{tar} will use the value of the environment
  3288. variable @env{TAPE}, or, if this has not been set, the default archive name.
  3289. @FIXME{There is no way to specify a new name...}
  3290. To demonstrate how @option{--concatenate} works, create two small archives
  3291. called @file{bluesrock.tar} and @file{folkjazz.tar}, using the relevant
  3292. files from @file{practice}:
  3293. @smallexample
  3294. $ @kbd{tar -cvf bluesrock.tar blues rock}
  3295. blues
  3296. rock
  3297. $ @kbd{tar -cvf folkjazz.tar folk jazz}
  3298. folk
  3299. jazz
  3300. @end smallexample
  3301. @noindent
  3302. If you like, You can run @samp{tar --list} to make sure the archives
  3303. contain what they are supposed to:
  3304. @smallexample
  3305. $ @kbd{tar -tvf bluesrock.tar}
  3306. -rw-r--r-- melissa user 105 1997-01-21 19:42 blues
  3307. -rw-r--r-- melissa user 33 1997-01-20 15:34 rock
  3308. $ @kbd{tar -tvf jazzfolk.tar}
  3309. -rw-r--r-- melissa user 20 1996-09-23 16:44 folk
  3310. -rw-r--r-- melissa user 65 1997-01-30 14:15 jazz
  3311. @end smallexample
  3312. We can concatenate these two archives with @command{tar}:
  3313. @smallexample
  3314. $ @kbd{cd ..}
  3315. $ @kbd{tar --concatenate --file=bluesrock.tar jazzfolk.tar}
  3316. @end smallexample
  3317. If you now list the contents of the @file{bluesrock.tar}, you will see
  3318. that now it also contains the archive members of @file{jazzfolk.tar}:
  3319. @smallexample
  3320. $ @kbd{tar --list --file=bluesrock.tar}
  3321. blues
  3322. rock
  3323. folk
  3324. jazz
  3325. @end smallexample
  3326. When you use @option{--concatenate}, the source and target archives must
  3327. already exist and must have been created using compatible format
  3328. parameters. Notice, that @command{tar} does not check whether the
  3329. archives it concatenates have compatible formats, it does not
  3330. even check if the files are really tar archives.
  3331. Like @option{--append} (@option{-r}), this operation cannot be performed on some
  3332. tape drives, due to deficiencies in the formats those tape drives use.
  3333. @cindex @code{concatenate} vs @command{cat}
  3334. @cindex @command{cat} vs @code{concatenate}
  3335. It may seem more intuitive to you to want or try to use @command{cat} to
  3336. concatenate two archives instead of using the @option{--concatenate}
  3337. operation; after all, @command{cat} is the utility for combining files.
  3338. However, @command{tar} archives incorporate an end-of-file marker which
  3339. must be removed if the concatenated archives are to be read properly as
  3340. one archive. @option{--concatenate} removes the end-of-archive marker
  3341. from the target archive before each new archive is appended. If you use
  3342. @command{cat} to combine the archives, the result will not be a valid
  3343. @command{tar} format archive. If you need to retrieve files from an
  3344. archive that was added to using the @command{cat} utility, use the
  3345. @option{--ignore-zeros} (@option{-i}) option. @xref{Ignore Zeros}, for further
  3346. information on dealing with archives improperly combined using the
  3347. @command{cat} shell utility.
  3348. @node delete
  3349. @subsection Removing Archive Members Using @option{--delete}
  3350. @UNREVISED
  3351. @cindex Deleting files from an archive
  3352. @cindex Removing files from an archive
  3353. @opindex delete
  3354. You can remove members from an archive by using the @option{--delete}
  3355. option. Specify the name of the archive with @option{--file}
  3356. (@option{-f}) and then specify the names of the members to be deleted;
  3357. if you list no member names, nothing will be deleted. The
  3358. @option{--verbose} option will cause @command{tar} to print the names
  3359. of the members as they are deleted. As with @option{--extract}, you
  3360. must give the exact member names when using @samp{tar --delete}.
  3361. @option{--delete} will remove all versions of the named file from the
  3362. archive. The @option{--delete} operation can run very slowly.
  3363. Unlike other operations, @option{--delete} has no short form.
  3364. @cindex Tapes, using @option{--delete} and
  3365. @cindex Deleting from tape archives
  3366. This operation will rewrite the archive. You can only use
  3367. @option{--delete} on an archive if the archive device allows you to
  3368. write to any point on the media, such as a disk; because of this, it
  3369. does not work on magnetic tapes. Do not try to delete an archive member
  3370. from a magnetic tape; the action will not succeed, and you will be
  3371. likely to scramble the archive and damage your tape. There is no safe
  3372. way (except by completely re-writing the archive) to delete files from
  3373. most kinds of magnetic tape. @xref{Media}.
  3374. To delete all versions of the file @file{blues} from the archive
  3375. @file{collection.tar} in the @file{practice} directory, make sure you
  3376. are in that directory, and then,
  3377. @smallexample
  3378. $ @kbd{tar --list --file=collection.tar}
  3379. blues
  3380. folk
  3381. jazz
  3382. rock
  3383. $ @kbd{tar --delete --file=collection.tar blues}
  3384. $ @kbd{tar --list --file=collection.tar}
  3385. folk
  3386. jazz
  3387. rock
  3388. $
  3389. @end smallexample
  3390. @FIXME{Check if the above listing is actually produced after running
  3391. all the examples on collection.tar.}
  3392. The @option{--delete} option has been reported to work properly when
  3393. @command{tar} acts as a filter from @code{stdin} to @code{stdout}.
  3394. @node compare
  3395. @subsection Comparing Archive Members with the File System
  3396. @cindex Verifying the currency of an archive
  3397. @UNREVISED
  3398. @opindex compare
  3399. The @option{--compare} (@option{-d}), or @option{--diff} operation compares
  3400. specified archive members against files with the same names, and then
  3401. reports differences in file size, mode, owner, modification date and
  3402. contents. You should @emph{only} specify archive member names, not file
  3403. names. If you do not name any members, then @command{tar} will compare the
  3404. entire archive. If a file is represented in the archive but does not
  3405. exist in the file system, @command{tar} reports a difference.
  3406. You have to specify the record size of the archive when modifying an
  3407. archive with a non-default record size.
  3408. @command{tar} ignores files in the file system that do not have
  3409. corresponding members in the archive.
  3410. The following example compares the archive members @file{rock},
  3411. @file{blues} and @file{funk} in the archive @file{bluesrock.tar} with
  3412. files of the same name in the file system. (Note that there is no file,
  3413. @file{funk}; @command{tar} will report an error message.)
  3414. @smallexample
  3415. $ @kbd{tar --compare --file=bluesrock.tar rock blues funk}
  3416. rock
  3417. blues
  3418. tar: funk not found in archive
  3419. @end smallexample
  3420. The spirit behind the @option{--compare} (@option{--diff},
  3421. @option{-d}) option is to check whether the archive represents the
  3422. current state of files on disk, more than validating the integrity of
  3423. the archive media. For this later goal, @xref{verify}.
  3424. @node create options
  3425. @section Options Used by @option{--create}
  3426. @xopindex{create, additional options}
  3427. The previous chapter described the basics of how to use
  3428. @option{--create} (@option{-c}) to create an archive from a set of files.
  3429. @xref{create}. This section described advanced options to be used with
  3430. @option{--create}.
  3431. @menu
  3432. * override:: Overriding File Metadata.
  3433. * Ignore Failed Read::
  3434. @end menu
  3435. @node override
  3436. @subsection Overriding File Metadata
  3437. As described above, a @command{tar} archive keeps, for each member it contains,
  3438. its @dfn{metadata}, such as modification time, mode and ownership of
  3439. the file. @GNUTAR{} allows to replace these data with other values
  3440. when adding files to the archive. The options described in this
  3441. section affect creation of archives of any type. For POSIX archives,
  3442. see also @ref{PAX keywords}, for additional ways of controlling
  3443. metadata, stored in the archive.
  3444. @table @option
  3445. @opindex mode
  3446. @item --mode=@var{permissions}
  3447. When adding files to an archive, @command{tar} will use
  3448. @var{permissions} for the archive members, rather than the permissions
  3449. from the files. @var{permissions} can be specified either as an octal
  3450. number or as symbolic permissions, like with
  3451. @command{chmod} (@xref{File permissions, Permissions, File
  3452. permissions, fileutils, @acronym{GNU} file utilities}. This reference
  3453. also has useful information for those not being overly familiar with
  3454. the UNIX permission system). Using latter syntax allows for
  3455. more flexibility. For example, the value @samp{a+rw} adds read and write
  3456. permissions for everybody, while retaining executable bits on directories
  3457. or on any other file already marked as executable:
  3458. @smallexample
  3459. $ @kbd{tar -c -f archive.tar --mode='a+rw' .}
  3460. @end smallexample
  3461. @item --mtime=@var{date}
  3462. @opindex mtime
  3463. When adding files to an archive, @command{tar} will use @var{date} as
  3464. the modification time of members when creating archives, instead of
  3465. their actual modification times. The argument @var{date} can be
  3466. either a textual date representation in almost arbitrary format
  3467. (@pxref{Date input formats}) or a name of the existing file, starting
  3468. with @samp{/} or @samp{.}. In the latter case, the modification time
  3469. of that file will be used.
  3470. The following example will set the modification date to 00:00:00 UTC,
  3471. January 1, 1970:
  3472. @smallexample
  3473. $ @kbd{tar -c -f archive.tar --mtime='1970-01-01' .}
  3474. @end smallexample
  3475. @noindent
  3476. When used with @option{--verbose} (@pxref{verbose tutorial}) @GNUTAR{}
  3477. will try to convert the specified date back to its textual
  3478. representation and compare it with the one given with
  3479. @option{--mtime} options. If the two dates differ, @command{tar} will
  3480. print a warning saying what date it will use. This is to help user
  3481. ensure he is using the right date.
  3482. For example:
  3483. @smallexample
  3484. $ @kbd{tar -c -f archive.tar -v --mtime=yesterday .}
  3485. tar: Option --mtime: Treating date `yesterday' as 2006-06-20
  3486. 13:06:29.152478
  3487. @dots{}
  3488. @end smallexample
  3489. @item --owner=@var{user}
  3490. @opindex owner
  3491. Specifies that @command{tar} should use @var{user} as the owner of members
  3492. when creating archives, instead of the user associated with the source
  3493. file. The argument @var{user} can be either an existing user symbolic
  3494. name, or a decimal numeric user @acronym{ID}.
  3495. There is no value indicating a missing number, and @samp{0} usually means
  3496. @code{root}. Some people like to force @samp{0} as the value to offer in
  3497. their distributions for the owner of files, because the @code{root} user is
  3498. anonymous anyway, so that might as well be the owner of anonymous
  3499. archives. For example:
  3500. @smallexample
  3501. @group
  3502. $ @kbd{tar -c -f archive.tar --owner=0 .}
  3503. # @r{Or:}
  3504. $ @kbd{tar -c -f archive.tar --owner=root .}
  3505. @end group
  3506. @end smallexample
  3507. @item --group=@var{group}
  3508. @opindex group
  3509. Files added to the @command{tar} archive will have a group @acronym{ID} of @var{group},
  3510. rather than the group from the source file. The argument @var{group}
  3511. can be either an existing group symbolic name, or a decimal numeric group @acronym{ID}.
  3512. @end table
  3513. @node Ignore Failed Read
  3514. @subsection Ignore Fail Read
  3515. @table @option
  3516. @item --ignore-failed-read
  3517. @opindex ignore-failed-read
  3518. Do not exit with nonzero on unreadable files or directories.
  3519. @end table
  3520. @node extract options
  3521. @section Options Used by @option{--extract}
  3522. @UNREVISED
  3523. @xopindex{extract, additional options}
  3524. The previous chapter showed how to use @option{--extract} to extract
  3525. an archive into the file system. Various options cause @command{tar} to
  3526. extract more information than just file contents, such as the owner,
  3527. the permissions, the modification date, and so forth. This section
  3528. presents options to be used with @option{--extract} when certain special
  3529. considerations arise. You may review the information presented in
  3530. @ref{extract} for more basic information about the
  3531. @option{--extract} operation.
  3532. @menu
  3533. * Reading:: Options to Help Read Archives
  3534. * Writing:: Changing How @command{tar} Writes Files
  3535. * Scarce:: Coping with Scarce Resources
  3536. @end menu
  3537. @node Reading
  3538. @subsection Options to Help Read Archives
  3539. @cindex Options when reading archives
  3540. @UNREVISED
  3541. @cindex Reading incomplete records
  3542. @cindex Records, incomplete
  3543. @opindex read-full-records
  3544. Normally, @command{tar} will request data in full record increments from
  3545. an archive storage device. If the device cannot return a full record,
  3546. @command{tar} will report an error. However, some devices do not always
  3547. return full records, or do not require the last record of an archive to
  3548. be padded out to the next record boundary. To keep reading until you
  3549. obtain a full record, or to accept an incomplete record if it contains
  3550. an end-of-archive marker, specify the @option{--read-full-records} (@option{-B}) option
  3551. in conjunction with the @option{--extract} or @option{--list} operations.
  3552. @xref{Blocking}.
  3553. The @option{--read-full-records} (@option{-B}) option is turned on by default when
  3554. @command{tar} reads an archive from standard input, or from a remote
  3555. machine. This is because on @acronym{BSD} Unix systems, attempting to read a
  3556. pipe returns however much happens to be in the pipe, even if it is
  3557. less than was requested. If this option were not enabled, @command{tar}
  3558. would fail as soon as it read an incomplete record from the pipe.
  3559. If you're not sure of the blocking factor of an archive, you can
  3560. read the archive by specifying @option{--read-full-records} (@option{-B}) and
  3561. @option{--blocking-factor=@var{512-size}} (@option{-b
  3562. @var{512-size}}), using a blocking factor larger than what the archive
  3563. uses. This lets you avoid having to determine the blocking factor
  3564. of an archive. @xref{Blocking Factor}.
  3565. @menu
  3566. * read full records::
  3567. * Ignore Zeros::
  3568. @end menu
  3569. @node read full records
  3570. @unnumberedsubsubsec Reading Full Records
  3571. @FIXME{need sentence or so of intro here}
  3572. @table @option
  3573. @opindex read-full-records
  3574. @item --read-full-records
  3575. @item -B
  3576. Use in conjunction with @option{--extract} (@option{--get},
  3577. @option{-x}) to read an archive which contains incomplete records, or
  3578. one which has a blocking factor less than the one specified.
  3579. @end table
  3580. @node Ignore Zeros
  3581. @unnumberedsubsubsec Ignoring Blocks of Zeros
  3582. @cindex End-of-archive blocks, ignoring
  3583. @cindex Ignoring end-of-archive blocks
  3584. @opindex ignore-zeros
  3585. Normally, @command{tar} stops reading when it encounters a block of zeros
  3586. between file entries (which usually indicates the end of the archive).
  3587. @option{--ignore-zeros} (@option{-i}) allows @command{tar} to
  3588. completely read an archive which contains a block of zeros before the
  3589. end (i.e., a damaged archive, or one that was created by concatenating
  3590. several archives together).
  3591. The @option{--ignore-zeros} (@option{-i}) option is turned off by default because many
  3592. versions of @command{tar} write garbage after the end-of-archive entry,
  3593. since that part of the media is never supposed to be read. @GNUTAR{}
  3594. does not write after the end of an archive, but seeks to
  3595. maintain compatibility among archiving utilities.
  3596. @table @option
  3597. @item --ignore-zeros
  3598. @itemx -i
  3599. To ignore blocks of zeros (i.e., end-of-archive entries) which may be
  3600. encountered while reading an archive. Use in conjunction with
  3601. @option{--extract} or @option{--list}.
  3602. @end table
  3603. @node Writing
  3604. @subsection Changing How @command{tar} Writes Files
  3605. @UNREVISED
  3606. @FIXME{Introductory paragraph}
  3607. @menu
  3608. * Dealing with Old Files::
  3609. * Overwrite Old Files::
  3610. * Keep Old Files::
  3611. * Keep Newer Files::
  3612. * Unlink First::
  3613. * Recursive Unlink::
  3614. * Data Modification Times::
  3615. * Setting Access Permissions::
  3616. * Directory Modification Times and Permissions::
  3617. * Writing to Standard Output::
  3618. * Writing to an External Program::
  3619. * remove files::
  3620. @end menu
  3621. @node Dealing with Old Files
  3622. @unnumberedsubsubsec Options Controlling the Overwriting of Existing Files
  3623. @xopindex{overwrite-dir, introduced}
  3624. When extracting files, if @command{tar} discovers that the extracted
  3625. file already exists, it normally replaces the file by removing it before
  3626. extracting it, to prevent confusion in the presence of hard or symbolic
  3627. links. (If the existing file is a symbolic link, it is removed, not
  3628. followed.) However, if a directory cannot be removed because it is
  3629. nonempty, @command{tar} normally overwrites its metadata (ownership,
  3630. permission, etc.). The @option{--overwrite-dir} option enables this
  3631. default behavior. To be more cautious and preserve the metadata of
  3632. such a directory, use the @option{--no-overwrite-dir} option.
  3633. @cindex Overwriting old files, prevention
  3634. @xopindex{keep-old-files, introduced}
  3635. To be even more cautious and prevent existing files from being replaced, use
  3636. the @option{--keep-old-files} (@option{-k}) option. It causes @command{tar} to refuse
  3637. to replace or update a file that already exists, i.e., a file with the
  3638. same name as an archive member prevents extraction of that archive
  3639. member. Instead, it reports an error.
  3640. @xopindex{overwrite, introduced}
  3641. To be more aggressive about altering existing files, use the
  3642. @option{--overwrite} option. It causes @command{tar} to overwrite
  3643. existing files and to follow existing symbolic links when extracting.
  3644. @cindex Protecting old files
  3645. Some people argue that @GNUTAR{} should not hesitate
  3646. to overwrite files with other files when extracting. When extracting
  3647. a @command{tar} archive, they expect to see a faithful copy of the
  3648. state of the file system when the archive was created. It is debatable
  3649. that this would always be a proper behavior. For example, suppose one
  3650. has an archive in which @file{usr/local} is a link to
  3651. @file{usr/local2}. Since then, maybe the site removed the link and
  3652. renamed the whole hierarchy from @file{/usr/local2} to
  3653. @file{/usr/local}. Such things happen all the time. I guess it would
  3654. not be welcome at all that @GNUTAR{} removes the
  3655. whole hierarchy just to make room for the link to be reinstated
  3656. (unless it @emph{also} simultaneously restores the full
  3657. @file{/usr/local2}, of course!) @GNUTAR{} is indeed
  3658. able to remove a whole hierarchy to reestablish a symbolic link, for
  3659. example, but @emph{only if} @option{--recursive-unlink} is specified
  3660. to allow this behavior. In any case, single files are silently
  3661. removed.
  3662. @xopindex{unlink-first, introduced}
  3663. Finally, the @option{--unlink-first} (@option{-U}) option can improve performance in
  3664. some cases by causing @command{tar} to remove files unconditionally
  3665. before extracting them.
  3666. @node Overwrite Old Files
  3667. @unnumberedsubsubsec Overwrite Old Files
  3668. @table @option
  3669. @opindex overwrite
  3670. @item --overwrite
  3671. Overwrite existing files and directory metadata when extracting files
  3672. from an archive.
  3673. This causes @command{tar} to write extracted files into the file system without
  3674. regard to the files already on the system; i.e., files with the same
  3675. names as archive members are overwritten when the archive is extracted.
  3676. It also causes @command{tar} to extract the ownership, permissions,
  3677. and time stamps onto any preexisting files or directories.
  3678. If the name of a corresponding file name is a symbolic link, the file
  3679. pointed to by the symbolic link will be overwritten instead of the
  3680. symbolic link itself (if this is possible). Moreover, special devices,
  3681. empty directories and even symbolic links are automatically removed if
  3682. they are in the way of extraction.
  3683. Be careful when using the @option{--overwrite} option, particularly when
  3684. combined with the @option{--absolute-names} (@option{-P}) option, as this combination
  3685. can change the contents, ownership or permissions of any file on your
  3686. system. Also, many systems do not take kindly to overwriting files that
  3687. are currently being executed.
  3688. @opindex overwrite-dir
  3689. @item --overwrite-dir
  3690. Overwrite the metadata of directories when extracting files from an
  3691. archive, but remove other files before extracting.
  3692. @end table
  3693. @node Keep Old Files
  3694. @unnumberedsubsubsec Keep Old Files
  3695. @table @option
  3696. @opindex keep-old-files
  3697. @item --keep-old-files
  3698. @itemx -k
  3699. Do not replace existing files from archive. The
  3700. @option{--keep-old-files} (@option{-k}) option prevents @command{tar}
  3701. from replacing existing files with files with the same name from the
  3702. archive. The @option{--keep-old-files} option is meaningless with
  3703. @option{--list} (@option{-t}). Prevents @command{tar} from replacing
  3704. files in the file system during extraction.
  3705. @end table
  3706. @node Keep Newer Files
  3707. @unnumberedsubsubsec Keep Newer Files
  3708. @table @option
  3709. @opindex keep-newer-files
  3710. @item --keep-newer-files
  3711. Do not replace existing files that are newer than their archive
  3712. copies. This option is meaningless with @option{--list} (@option{-t}).
  3713. @end table
  3714. @node Unlink First
  3715. @unnumberedsubsubsec Unlink First
  3716. @table @option
  3717. @opindex unlink-first
  3718. @item --unlink-first
  3719. @itemx -U
  3720. Remove files before extracting over them.
  3721. This can make @command{tar} run a bit faster if you know in advance
  3722. that the extracted files all need to be removed. Normally this option
  3723. slows @command{tar} down slightly, so it is disabled by default.
  3724. @end table
  3725. @node Recursive Unlink
  3726. @unnumberedsubsubsec Recursive Unlink
  3727. @table @option
  3728. @opindex recursive-unlink
  3729. @item --recursive-unlink
  3730. When this option is specified, try removing files and directory hierarchies
  3731. before extracting over them. @emph{This is a dangerous option!}
  3732. @end table
  3733. If you specify the @option{--recursive-unlink} option,
  3734. @command{tar} removes @emph{anything} that keeps you from extracting a file
  3735. as far as current permissions will allow it. This could include removal
  3736. of the contents of a full directory hierarchy.
  3737. @node Data Modification Times
  3738. @unnumberedsubsubsec Setting Data Modification Times
  3739. @cindex Data modification times of extracted files
  3740. @cindex Modification times of extracted files
  3741. Normally, @command{tar} sets the data modification times of extracted
  3742. files to the corresponding times recorded for the files in the archive, but
  3743. limits the permissions of extracted files by the current @code{umask}
  3744. setting.
  3745. To set the data modification times of extracted files to the time when
  3746. the files were extracted, use the @option{--touch} (@option{-m}) option in
  3747. conjunction with @option{--extract} (@option{--get}, @option{-x}).
  3748. @table @option
  3749. @opindex touch
  3750. @item --touch
  3751. @itemx -m
  3752. Sets the data modification time of extracted archive members to the time
  3753. they were extracted, not the time recorded for them in the archive.
  3754. Use in conjunction with @option{--extract} (@option{--get}, @option{-x}).
  3755. @end table
  3756. @node Setting Access Permissions
  3757. @unnumberedsubsubsec Setting Access Permissions
  3758. @cindex Permissions of extracted files
  3759. @cindex Modes of extracted files
  3760. To set the modes (access permissions) of extracted files to those
  3761. recorded for those files in the archive, use @option{--same-permissions}
  3762. in conjunction with the @option{--extract} (@option{--get},
  3763. @option{-x}) operation.
  3764. @table @option
  3765. @opindex preserve-permissions
  3766. @opindex same-permissions
  3767. @item --preserve-permissions
  3768. @itemx --same-permissions
  3769. @c @itemx --ignore-umask
  3770. @itemx -p
  3771. Set modes of extracted archive members to those recorded in the
  3772. archive, instead of current umask settings. Use in conjunction with
  3773. @option{--extract} (@option{--get}, @option{-x}).
  3774. @end table
  3775. @node Directory Modification Times and Permissions
  3776. @unnumberedsubsubsec Directory Modification Times and Permissions
  3777. After successfully extracting a file member, @GNUTAR{} normally
  3778. restores its permissions and modification times, as described in the
  3779. previous sections. This cannot be done for directories, because
  3780. after extracting a directory @command{tar} will almost certainly
  3781. extract files into that directory and this will cause the directory
  3782. modification time to be updated. Moreover, restoring that directory
  3783. permissions may not permit file creation within it. Thus, restoring
  3784. directory permissions and modification times must be delayed at least
  3785. until all files have been extracted into that directory. @GNUTAR{}
  3786. restores directories using the following approach.
  3787. The extracted directories are created with the mode specified in the
  3788. archive, as modified by the umask of the user, which gives sufficient
  3789. permissions to allow file creation. The meta-information about the
  3790. directory is recorded in the temporary list of directories. When
  3791. preparing to extract next archive member, @GNUTAR{} checks if the
  3792. directory prefix of this file contains the remembered directory. If
  3793. it does not, the program assumes that all files have been extracted
  3794. into that directory, restores its modification time and permissions
  3795. and removes its entry from the internal list. This approach allows
  3796. to correctly restore directory meta-information in the majority of
  3797. cases, while keeping memory requirements sufficiently small. It is
  3798. based on the fact, that most @command{tar} archives use the predefined
  3799. order of members: first the directory, then all the files and
  3800. subdirectories in that directory.
  3801. However, this is not always true. The most important exception are
  3802. incremental archives (@pxref{Incremental Dumps}). The member order in
  3803. an incremental archive is reversed: first all directory members are
  3804. stored, followed by other (non-directory) members. So, when extracting
  3805. from incremental archives, @GNUTAR{} alters the above procedure. It
  3806. remembers all restored directories, and restores their meta-data
  3807. only after the entire archive has been processed. Notice, that you do
  3808. not need to specify any special options for that, as @GNUTAR{}
  3809. automatically detects archives in incremental format.
  3810. There may be cases, when such processing is required for normal archives
  3811. too. Consider the following example:
  3812. @smallexample
  3813. @group
  3814. $ @kbd{tar --no-recursion -cvf archive \
  3815. foo foo/file1 bar bar/file foo/file2}
  3816. foo/
  3817. foo/file1
  3818. bar/
  3819. bar/file
  3820. foo/file2
  3821. @end group
  3822. @end smallexample
  3823. During the normal operation, after encountering @file{bar}
  3824. @GNUTAR{} will assume that all files from the directory @file{foo}
  3825. were already extracted and will therefore restore its timestamp and
  3826. permission bits. However, after extracting @file{foo/file2} the
  3827. directory timestamp will be offset again.
  3828. To correctly restore directory meta-information in such cases, use
  3829. @option{delay-directory-restore} command line option:
  3830. @table @option
  3831. @opindex delay-directory-restore
  3832. @item --delay-directory-restore
  3833. Delays restoring of the modification times and permissions of extracted
  3834. directories until the end of extraction. This way, correct
  3835. meta-information is restored even if the archive has unusual member
  3836. ordering.
  3837. @opindex no-delay-directory-restore
  3838. @item --no-delay-directory-restore
  3839. Cancel the effect of the previous @option{--delay-directory-restore}.
  3840. Use this option if you have used @option{--delay-directory-restore} in
  3841. @env{TAR_OPTIONS} variable (@pxref{TAR_OPTIONS}) and wish to
  3842. temporarily disable it.
  3843. @end table
  3844. @node Writing to Standard Output
  3845. @unnumberedsubsubsec Writing to Standard Output
  3846. @cindex Writing extracted files to standard output
  3847. @cindex Standard output, writing extracted files to
  3848. To write the extracted files to the standard output, instead of
  3849. creating the files on the file system, use @option{--to-stdout} (@option{-O}) in
  3850. conjunction with @option{--extract} (@option{--get}, @option{-x}). This option is useful if you are
  3851. extracting files to send them through a pipe, and do not need to
  3852. preserve them in the file system. If you extract multiple members,
  3853. they appear on standard output concatenated, in the order they are
  3854. found in the archive.
  3855. @table @option
  3856. @opindex to-stdout
  3857. @item --to-stdout
  3858. @itemx -O
  3859. Writes files to the standard output. Use only in conjunction with
  3860. @option{--extract} (@option{--get}, @option{-x}). When this option is
  3861. used, instead of creating the files specified, @command{tar} writes
  3862. the contents of the files extracted to its standard output. This may
  3863. be useful if you are only extracting the files in order to send them
  3864. through a pipe. This option is meaningless with @option{--list}
  3865. (@option{-t}).
  3866. @end table
  3867. This can be useful, for example, if you have a tar archive containing
  3868. a big file and don't want to store the file on disk before processing
  3869. it. You can use a command like this:
  3870. @smallexample
  3871. tar -xOzf foo.tgz bigfile | process
  3872. @end smallexample
  3873. or even like this if you want to process the concatenation of the files:
  3874. @smallexample
  3875. tar -xOzf foo.tgz bigfile1 bigfile2 | process
  3876. @end smallexample
  3877. However, @option{--to-command} may be more convenient for use with
  3878. multiple files. See the next section.
  3879. @node Writing to an External Program
  3880. @unnumberedsubsubsec Writing to an External Program
  3881. You can instruct @command{tar} to send the contents of each extracted
  3882. file to the standard input of an external program:
  3883. @table @option
  3884. @opindex to-command
  3885. @item --to-command=@var{command}
  3886. Extract files and pipe their contents to the standard input of
  3887. @var{command}. When this option is used, instead of creating the
  3888. files specified, @command{tar} invokes @var{command} and pipes the
  3889. contents of the files to its standard output. @var{Command} may
  3890. contain command line arguments. The program is executed via
  3891. @code{sh -c}. Notice, that @var{command} is executed once for each regular file
  3892. extracted. Non-regular files (directories, etc.) are ignored when this
  3893. option is used.
  3894. @end table
  3895. The command can obtain the information about the file it processes
  3896. from the following environment variables:
  3897. @table @var
  3898. @vrindex TAR_FILETYPE, to-command environment
  3899. @item TAR_FILETYPE
  3900. Type of the file. It is a single letter with the following meaning:
  3901. @multitable @columnfractions 0.10 0.90
  3902. @item f @tab Regular file
  3903. @item d @tab Directory
  3904. @item l @tab Symbolic link
  3905. @item h @tab Hard link
  3906. @item b @tab Block device
  3907. @item c @tab Character device
  3908. @end multitable
  3909. Currently only regular files are supported.
  3910. @vrindex TAR_MODE, to-command environment
  3911. @item TAR_MODE
  3912. File mode, an octal number.
  3913. @vrindex TAR_FILENAME, to-command environment
  3914. @item TAR_FILENAME
  3915. The name of the file.
  3916. @vrindex TAR_REALNAME, to-command environment
  3917. @item TAR_REALNAME
  3918. Name of the file as stored in the archive.
  3919. @vrindex TAR_UNAME, to-command environment
  3920. @item TAR_UNAME
  3921. Name of the file owner.
  3922. @vrindex TAR_GNAME, to-command environment
  3923. @item TAR_GNAME
  3924. Name of the file owner group.
  3925. @vrindex TAR_ATIME, to-command environment
  3926. @item TAR_ATIME
  3927. Time of last access. It is a decimal number, representing seconds
  3928. since the epoch. If the archive provides times with nanosecond
  3929. precision, the nanoseconds are appended to the timestamp after a
  3930. decimal point.
  3931. @vrindex TAR_MTIME, to-command environment
  3932. @item TAR_MTIME
  3933. Time of last modification.
  3934. @vrindex TAR_CTIME, to-command environment
  3935. @item TAR_CTIME
  3936. Time of last status change.
  3937. @vrindex TAR_SIZE, to-command environment
  3938. @item TAR_SIZE
  3939. Size of the file.
  3940. @vrindex TAR_UID, to-command environment
  3941. @item TAR_UID
  3942. UID of the file owner.
  3943. @vrindex TAR_GID, to-command environment
  3944. @item TAR_GID
  3945. GID of the file owner.
  3946. @end table
  3947. In addition to these variables, @env{TAR_VERSION} contains the
  3948. @GNUTAR{} version number.
  3949. If @var{command} exits with a non-0 status, @command{tar} will print
  3950. an error message similar to the following:
  3951. @smallexample
  3952. tar: 2345: Child returned status 1
  3953. @end smallexample
  3954. Here, @samp{2345} is the PID of the finished process.
  3955. If this behavior is not wanted, use @option{--ignore-command-error}:
  3956. @table @option
  3957. @opindex ignore-command-error
  3958. @item --ignore-command-error
  3959. Ignore exit codes of subprocesses. Notice that if the program
  3960. exits on signal or otherwise terminates abnormally, the error message
  3961. will be printed even if this option is used.
  3962. @opindex no-ignore-command-error
  3963. @item --no-ignore-command-error
  3964. Cancel the effect of any previous @option{--ignore-command-error}
  3965. option. This option is useful if you have set
  3966. @option{--ignore-command-error} in @env{TAR_OPTIONS}
  3967. (@pxref{TAR_OPTIONS}) and wish to temporarily cancel it.
  3968. @end table
  3969. @node remove files
  3970. @unnumberedsubsubsec Removing Files
  3971. @FIXME{The section is too terse. Something more to add? An example,
  3972. maybe?}
  3973. @table @option
  3974. @opindex remove-files
  3975. @item --remove-files
  3976. Remove files after adding them to the archive.
  3977. @end table
  3978. @node Scarce
  3979. @subsection Coping with Scarce Resources
  3980. @UNREVISED
  3981. @cindex Small memory
  3982. @cindex Running out of space
  3983. @menu
  3984. * Starting File::
  3985. * Same Order::
  3986. @end menu
  3987. @node Starting File
  3988. @unnumberedsubsubsec Starting File
  3989. @table @option
  3990. @opindex starting-file
  3991. @item --starting-file=@var{name}
  3992. @itemx -K @var{name}
  3993. Starts an operation in the middle of an archive. Use in conjunction
  3994. with @option{--extract} (@option{--get}, @option{-x}) or @option{--list} (@option{-t}).
  3995. @end table
  3996. @cindex Middle of the archive, starting in the
  3997. If a previous attempt to extract files failed due to lack of disk
  3998. space, you can use @option{--starting-file=@var{name}} (@option{-K
  3999. @var{name}}) to start extracting only after member @var{name} of the
  4000. archive. This assumes, of course, that there is now free space, or
  4001. that you are now extracting into a different file system. (You could
  4002. also choose to suspend @command{tar}, remove unnecessary files from
  4003. the file system, and then restart the same @command{tar} operation.
  4004. In this case, @option{--starting-file} is not necessary.
  4005. @xref{Incremental Dumps}, @xref{interactive}, and @ref{exclude}.)
  4006. @node Same Order
  4007. @unnumberedsubsubsec Same Order
  4008. @table @option
  4009. @cindex Large lists of file names on small machines
  4010. @opindex same-order
  4011. @opindex preserve-order
  4012. @item --same-order
  4013. @itemx --preserve-order
  4014. @itemx -s
  4015. To process large lists of file names on machines with small amounts of
  4016. memory. Use in conjunction with @option{--compare} (@option{--diff},
  4017. @option{-d}), @option{--list} (@option{-t}) or @option{--extract}
  4018. (@option{--get}, @option{-x}).
  4019. @end table
  4020. The @option{--same-order} (@option{--preserve-order}, @option{-s}) option tells @command{tar} that the list of file
  4021. names to be listed or extracted is sorted in the same order as the
  4022. files in the archive. This allows a large list of names to be used,
  4023. even on a small machine that would not otherwise be able to hold all
  4024. the names in memory at the same time. Such a sorted list can easily be
  4025. created by running @samp{tar -t} on the archive and editing its output.
  4026. This option is probably never needed on modern computer systems.
  4027. @node backup
  4028. @section Backup options
  4029. @cindex backup options
  4030. @GNUTAR{} offers options for making backups of files
  4031. before writing new versions. These options control the details of
  4032. these backups. They may apply to the archive itself before it is
  4033. created or rewritten, as well as individual extracted members. Other
  4034. @acronym{GNU} programs (@command{cp}, @command{install}, @command{ln},
  4035. and @command{mv}, for example) offer similar options.
  4036. Backup options may prove unexpectedly useful when extracting archives
  4037. containing many members having identical name, or when extracting archives
  4038. on systems having file name limitations, making different members appear
  4039. has having similar names through the side-effect of name truncation.
  4040. (This is true only if we have a good scheme for truncated backup names,
  4041. which I'm not sure at all: I suspect work is needed in this area.)
  4042. When any existing file is backed up before being overwritten by extraction,
  4043. then clashing files are automatically be renamed to be unique, and the
  4044. true name is kept for only the last file of a series of clashing files.
  4045. By using verbose mode, users may track exactly what happens.
  4046. At the detail level, some decisions are still experimental, and may
  4047. change in the future, we are waiting comments from our users. So, please
  4048. do not learn to depend blindly on the details of the backup features.
  4049. For example, currently, directories themselves are never renamed through
  4050. using these options, so, extracting a file over a directory still has
  4051. good chances to fail. Also, backup options apply to created archives,
  4052. not only to extracted members. For created archives, backups will not
  4053. be attempted when the archive is a block or character device, or when it
  4054. refers to a remote file.
  4055. For the sake of simplicity and efficiency, backups are made by renaming old
  4056. files prior to creation or extraction, and not by copying. The original
  4057. name is restored if the file creation fails. If a failure occurs after a
  4058. partial extraction of a file, both the backup and the partially extracted
  4059. file are kept.
  4060. @table @samp
  4061. @item --backup[=@var{method}]
  4062. @opindex backup
  4063. @vindex VERSION_CONTROL
  4064. @cindex backups
  4065. Back up files that are about to be overwritten or removed.
  4066. Without this option, the original versions are destroyed.
  4067. Use @var{method} to determine the type of backups made.
  4068. If @var{method} is not specified, use the value of the @env{VERSION_CONTROL}
  4069. environment variable. And if @env{VERSION_CONTROL} is not set,
  4070. use the @samp{existing} method.
  4071. @vindex version-control @r{Emacs variable}
  4072. This option corresponds to the Emacs variable @samp{version-control};
  4073. the same values for @var{method} are accepted as in Emacs. This option
  4074. also allows more descriptive names. The valid @var{method}s are:
  4075. @table @samp
  4076. @item t
  4077. @itemx numbered
  4078. @cindex numbered @r{backup method}
  4079. Always make numbered backups.
  4080. @item nil
  4081. @itemx existing
  4082. @cindex existing @r{backup method}
  4083. Make numbered backups of files that already have them, simple backups
  4084. of the others.
  4085. @item never
  4086. @itemx simple
  4087. @cindex simple @r{backup method}
  4088. Always make simple backups.
  4089. @end table
  4090. @item --suffix=@var{suffix}
  4091. @opindex suffix
  4092. @cindex backup suffix
  4093. @vindex SIMPLE_BACKUP_SUFFIX
  4094. Append @var{suffix} to each backup file made with @option{--backup}. If this
  4095. option is not specified, the value of the @env{SIMPLE_BACKUP_SUFFIX}
  4096. environment variable is used. And if @env{SIMPLE_BACKUP_SUFFIX} is not
  4097. set, the default is @samp{~}, just as in Emacs.
  4098. @end table
  4099. @node Applications
  4100. @section Notable @command{tar} Usages
  4101. @UNREVISED
  4102. @FIXME{Using Unix file linking capability to recreate directory
  4103. structures---linking files into one subdirectory and then
  4104. @command{tar}ring that directory.}
  4105. @FIXME{Nice hairy example using absolute-names, newer, etc.}
  4106. @findex uuencode
  4107. You can easily use archive files to transport a group of files from
  4108. one system to another: put all relevant files into an archive on one
  4109. computer system, transfer the archive to another system, and extract
  4110. the contents there. The basic transfer medium might be magnetic tape,
  4111. Internet FTP, or even electronic mail (though you must encode the
  4112. archive with @command{uuencode} in order to transport it properly by
  4113. mail). Both machines do not have to use the same operating system, as
  4114. long as they both support the @command{tar} program.
  4115. For example, here is how you might copy a directory's contents from
  4116. one disk to another, while preserving the dates, modes, owners and
  4117. link-structure of all the files therein. In this case, the transfer
  4118. medium is a @dfn{pipe}, which is one a Unix redirection mechanism:
  4119. @smallexample
  4120. $ @kbd{(cd sourcedir; tar -cf - .) | (cd targetdir; tar -xf -)}
  4121. @end smallexample
  4122. @noindent
  4123. You can avoid subshells by using @option{-C} option:
  4124. @smallexample
  4125. $ @kbd{tar -C sourcedir -cf - . | tar -C targetdir -xf -}
  4126. @end smallexample
  4127. @noindent
  4128. The command also works using short option forms:
  4129. @smallexample
  4130. $ @kbd{(cd sourcedir; tar --create --file=- . ) \
  4131. | (cd targetdir; tar --extract --file=-)}
  4132. # Or:
  4133. $ @kbd{tar --directory sourcedir --create --file=- . ) \
  4134. | tar --directory targetdir --extract --file=-}
  4135. @end smallexample
  4136. @noindent
  4137. This is one of the easiest methods to transfer a @command{tar} archive.
  4138. @node looking ahead
  4139. @section Looking Ahead: The Rest of this Manual
  4140. You have now seen how to use all eight of the operations available to
  4141. @command{tar}, and a number of the possible options. The next chapter
  4142. explains how to choose and change file and archive names, how to use
  4143. files to store names of other files which you can then call as
  4144. arguments to @command{tar} (this can help you save time if you expect to
  4145. archive the same list of files a number of times), and so forth.
  4146. @FIXME{in case it's not obvious, i'm making this up in some sense
  4147. based on my limited memory of what the next chapter *really* does. i
  4148. just wanted to flesh out this final section a little bit so i'd
  4149. remember to stick it in here. :-)}
  4150. If there are too many files to conveniently list on the command line,
  4151. you can list the names in a file, and @command{tar} will read that file.
  4152. @xref{files}.
  4153. There are various ways of causing @command{tar} to skip over some files,
  4154. and not archive them. @xref{Choosing}.
  4155. @node Backups
  4156. @chapter Performing Backups and Restoring Files
  4157. @UNREVISED
  4158. @GNUTAR{} is distributed along with the scripts
  4159. which the Free Software Foundation uses for performing backups. There
  4160. is no corresponding scripts available yet for doing restoration of
  4161. files. Even if there is a good chance those scripts may be satisfying
  4162. to you, they are not the only scripts or methods available for doing
  4163. backups and restore. You may well create your own, or use more
  4164. sophisticated packages dedicated to that purpose.
  4165. Some users are enthusiastic about @code{Amanda} (The Advanced Maryland
  4166. Automatic Network Disk Archiver), a backup system developed by James
  4167. da Silva @file{jds@@cs.umd.edu} and available on many Unix systems.
  4168. This is free software, and it is available at these places:
  4169. @smallexample
  4170. http://www.cs.umd.edu/projects/amanda/amanda.html
  4171. ftp://ftp.cs.umd.edu/pub/amanda
  4172. @end smallexample
  4173. @FIXME{
  4174. Here is a possible plan for a future documentation about the backuping
  4175. scripts which are provided within the @GNUTAR{}
  4176. distribution.
  4177. @itemize @bullet
  4178. @item dumps
  4179. @itemize @minus
  4180. @item what are dumps
  4181. @item different levels of dumps
  4182. @itemize +
  4183. @item full dump = dump everything
  4184. @item level 1, level 2 dumps etc
  4185. A level @var{n} dump dumps everything changed since the last level
  4186. @var{n}-1 dump (?)
  4187. @end itemize
  4188. @item how to use scripts for dumps (ie, the concept)
  4189. @itemize +
  4190. @item scripts to run after editing backup specs (details)
  4191. @end itemize
  4192. @item Backup Specs, what is it.
  4193. @itemize +
  4194. @item how to customize
  4195. @item actual text of script [/sp/dump/backup-specs]
  4196. @end itemize
  4197. @item Problems
  4198. @itemize +
  4199. @item rsh doesn't work
  4200. @item rtape isn't installed
  4201. @item (others?)
  4202. @end itemize
  4203. @item the @option{--incremental} option of tar
  4204. @item tapes
  4205. @itemize +
  4206. @item write protection
  4207. @item types of media, different sizes and types, useful for different things
  4208. @item files and tape marks
  4209. one tape mark between files, two at end.
  4210. @item positioning the tape
  4211. MT writes two at end of write,
  4212. backspaces over one when writing again.
  4213. @end itemize
  4214. @end itemize
  4215. @end itemize
  4216. }
  4217. This chapter documents both the provided shell scripts and @command{tar}
  4218. options which are more specific to usage as a backup tool.
  4219. To @dfn{back up} a file system means to create archives that contain
  4220. all the files in that file system. Those archives can then be used to
  4221. restore any or all of those files (for instance if a disk crashes or a
  4222. file is accidentally deleted). File system @dfn{backups} are also
  4223. called @dfn{dumps}.
  4224. @menu
  4225. * Full Dumps:: Using @command{tar} to Perform Full Dumps
  4226. * Incremental Dumps:: Using @command{tar} to Perform Incremental Dumps
  4227. * Backup Levels:: Levels of Backups
  4228. * Backup Parameters:: Setting Parameters for Backups and Restoration
  4229. * Scripted Backups:: Using the Backup Scripts
  4230. * Scripted Restoration:: Using the Restore Script
  4231. @end menu
  4232. @node Full Dumps
  4233. @section Using @command{tar} to Perform Full Dumps
  4234. @UNREVISED
  4235. @cindex full dumps
  4236. @cindex dumps, full
  4237. @cindex corrupted archives
  4238. Full dumps should only be made when no other people or programs
  4239. are modifying files in the file system. If files are modified while
  4240. @command{tar} is making the backup, they may not be stored properly in
  4241. the archive, in which case you won't be able to restore them if you
  4242. have to. (Files not being modified are written with no trouble, and do
  4243. not corrupt the entire archive.)
  4244. You will want to use the @option{--label=@var{archive-label}}
  4245. (@option{-V @var{archive-label}}) option to give the archive a
  4246. volume label, so you can tell what this archive is even if the label
  4247. falls off the tape, or anything like that.
  4248. Unless the file system you are dumping is guaranteed to fit on
  4249. one volume, you will need to use the @option{--multi-volume} (@option{-M}) option.
  4250. Make sure you have enough tapes on hand to complete the backup.
  4251. If you want to dump each file system separately you will need to use
  4252. the @option{--one-file-system} option to prevent
  4253. @command{tar} from crossing file system boundaries when storing
  4254. (sub)directories.
  4255. The @option{--incremental} (@option{-G}) (@pxref{Incremental Dumps})
  4256. option is not needed, since this is a complete copy of everything in
  4257. the file system, and a full restore from this backup would only be
  4258. done onto a completely
  4259. empty disk.
  4260. Unless you are in a hurry, and trust the @command{tar} program (and your
  4261. tapes), it is a good idea to use the @option{--verify} (@option{-W})
  4262. option, to make sure your files really made it onto the dump properly.
  4263. This will also detect cases where the file was modified while (or just
  4264. after) it was being archived. Not all media (notably cartridge tapes)
  4265. are capable of being verified, unfortunately.
  4266. @node Incremental Dumps
  4267. @section Using @command{tar} to Perform Incremental Dumps
  4268. @dfn{Incremental backup} is a special form of @GNUTAR{} archive that
  4269. stores additional metadata so that exact state of the file system
  4270. can be restored when extracting the archive.
  4271. @GNUTAR{} currently offers two options for handling incremental
  4272. backups: @option{--listed-incremental=@var{snapshot-file}} (@option{-g
  4273. @var{snapshot-file}}) and @option{--incremental} (@option{-G}).
  4274. @opindex listed-incremental
  4275. The option @option{--listed-incremental} instructs tar to operate on
  4276. an incremental archive with additional metadata stored in a standalone
  4277. file, called a @dfn{snapshot file}. The purpose of this file is to help
  4278. determine which files have been changed, added or deleted since the
  4279. last backup, so that the next incremental backup will contain only
  4280. modified files. The name of the snapshot file is given as an argument
  4281. to the option:
  4282. @table @option
  4283. @item --listed-incremental=@var{file}
  4284. @itemx -g @var{file}
  4285. Handle incremental backups with snapshot data in @var{file}.
  4286. @end table
  4287. To create an incremental backup, you would use
  4288. @option{--listed-incremental} together with @option{--create}
  4289. (@pxref{create}). For example:
  4290. @smallexample
  4291. $ @kbd{tar --create \
  4292. --file=archive.1.tar \
  4293. --listed-incremental=/var/log/usr.snar \
  4294. /usr}
  4295. @end smallexample
  4296. This will create in @file{archive.1.tar} an incremental backup of
  4297. the @file{/usr} file system, storing additional metadata in the file
  4298. @file{/var/log/usr.snar}. If this file does not exist, it will be
  4299. created. The created archive will then be a @dfn{level 0 backup};
  4300. please see the next section for more on backup levels.
  4301. Otherwise, if the file @file{/var/log/usr.snar} exists, it
  4302. determines which files are modified. In this case only these files will be
  4303. stored in the archive. Suppose, for example, that after running the
  4304. above command, you delete file @file{/usr/doc/old} and create
  4305. directory @file{/usr/local/db} with the following contents:
  4306. @smallexample
  4307. $ @kbd{ls /usr/local/db}
  4308. /usr/local/db/data
  4309. /usr/local/db/index
  4310. @end smallexample
  4311. Some time later you create another incremental backup. You will
  4312. then see:
  4313. @smallexample
  4314. $ @kbd{tar --create \
  4315. --file=archive.2.tar \
  4316. --listed-incremental=/var/log/usr.snar \
  4317. /usr}
  4318. tar: usr/local/db: Directory is new
  4319. usr/local/db/
  4320. usr/local/db/data
  4321. usr/local/db/index
  4322. @end smallexample
  4323. @noindent
  4324. The created archive @file{archive.2.tar} will contain only these
  4325. three members. This archive is called a @dfn{level 1 backup}. Notice
  4326. that @file{/var/log/usr.snar} will be updated with the new data, so if
  4327. you plan to create more @samp{level 1} backups, it is necessary to
  4328. create a working copy of the snapshot file before running
  4329. @command{tar}. The above example will then be modified as follows:
  4330. @smallexample
  4331. $ @kbd{cp /var/log/usr.snar /var/log/usr.snar-1}
  4332. $ @kbd{tar --create \
  4333. --file=archive.2.tar \
  4334. --listed-incremental=/var/log/usr.snar-1 \
  4335. /usr}
  4336. @end smallexample
  4337. Incremental dumps depend crucially on time stamps, so the results are
  4338. unreliable if you modify a file's time stamps during dumping (e.g.,
  4339. with the @option{--atime-preserve=replace} option), or if you set the clock
  4340. backwards.
  4341. @cindex Device numbers, using in incremental backups
  4342. Metadata stored in snapshot files include device numbers, which,
  4343. obviously is supposed to be a non-volatile value. However, it turns
  4344. out that NFS devices have undependable values when an automounter
  4345. gets in the picture. This can lead to a great deal of spurious
  4346. redumping in incremental dumps, so it is somewhat useless to compare
  4347. two NFS devices numbers over time. The solution implemented currently
  4348. is to considers all NFS devices as being equal when it comes to
  4349. comparing directories; this is fairly gross, but there does not seem
  4350. to be a better way to go.
  4351. If you are using the @i{Linux} kernel, the device numbers can also
  4352. change when upgrading to some newer versions of the kernel. This can
  4353. cause the next backup to be full backup on the affected filesystems.
  4354. @xref{Fixing Snapshot Files}, for the information on how to handle this case.
  4355. Note that incremental archives use @command{tar} extensions and may
  4356. not be readable by non-@acronym{GNU} versions of the @command{tar} program.
  4357. @xopindex{listed-incremental, using with @option{--extract}}
  4358. @xopindex{extract, using with @option{--listed-incremental}}
  4359. To extract from the incremental dumps, use
  4360. @option{--listed-incremental} together with @option{--extract}
  4361. option (@pxref{extracting files}). In this case, @command{tar} does
  4362. not need to access snapshot file, since all the data necessary for
  4363. extraction are stored in the archive itself. So, when extracting, you
  4364. can give whatever argument to @option{--listed-incremental}, the usual
  4365. practice is to use @option{--listed-incremental=/dev/null}.
  4366. Alternatively, you can use @option{--incremental}, which needs no
  4367. arguments. In general, @option{--incremental} (@option{-G}) can be
  4368. used as a shortcut for @option{--listed-incremental} when listing or
  4369. extracting incremental backups (for more information, regarding this
  4370. option, @pxref{incremental-op}).
  4371. When extracting from the incremental backup @GNUTAR{} attempts to
  4372. restore the exact state the file system had when the archive was
  4373. created. In particular, it will @emph{delete} those files in the file
  4374. system that did not exist in their directories when the archive was
  4375. created. If you have created several levels of incremental files,
  4376. then in order to restore the exact contents the file system had when
  4377. the last level was created, you will need to restore from all backups
  4378. in turn. Continuing our example, to restore the state of @file{/usr}
  4379. file system, one would do@footnote{Notice, that since both archives
  4380. were created without @option{-P} option (@pxref{absolute}), these
  4381. commands should be run from the root file system.}:
  4382. @smallexample
  4383. $ @kbd{tar --extract \
  4384. --listed-incremental=/dev/null \
  4385. --file archive.1.tar}
  4386. $ @kbd{tar --extract \
  4387. --listed-incremental=/dev/null \
  4388. --file archive.2.tar}
  4389. @end smallexample
  4390. To list the contents of an incremental archive, use @option{--list}
  4391. (@pxref{list}), as usual. To obtain more information about the
  4392. archive, use @option{--listed-incremental} or @option{--incremental}
  4393. combined with two @option{--verbose} options@footnote{Two
  4394. @option{--verbose} options were selected to avoid breaking usual
  4395. verbose listing output (@option{--list --verbose}) when using in
  4396. scripts.
  4397. @xopindex{incremental, using with @option{--list}}
  4398. @xopindex{listed-incremental, using with @option{--list}}
  4399. @xopindex{list, using with @option{--incremental}}
  4400. @xopindex{list, using with @option{--listed-incremental}}
  4401. Versions of @GNUTAR{} up to 1.15.1 used to dump verbatim binary
  4402. contents of the DUMPDIR header (with terminating nulls) when
  4403. @option{--incremental} or @option{--listed-incremental} option was
  4404. given, no matter what the verbosity level. This behavior, and,
  4405. especially, the binary output it produced were considered inconvenient
  4406. and were changed in version 1.16}:
  4407. @smallexample
  4408. @kbd{tar --list --incremental --verbose --verbose archive.tar}
  4409. @end smallexample
  4410. This command will print, for each directory in the archive, the list
  4411. of files in that directory at the time the archive was created. This
  4412. information is put out in a format which is both human-readable and
  4413. unambiguous for a program: each file name is printed as
  4414. @smallexample
  4415. @var{x} @var{file}
  4416. @end smallexample
  4417. @noindent
  4418. where @var{x} is a letter describing the status of the file: @samp{Y}
  4419. if the file is present in the archive, @samp{N} if the file is not
  4420. included in the archive, or a @samp{D} if the file is a directory (and
  4421. is included in the archive). @xref{Dumpdir}, for the detailed
  4422. description of dumpdirs and status codes. Each such
  4423. line is terminated by a newline character. The last line is followed
  4424. by an additional newline to indicate the end of the data.
  4425. @anchor{incremental-op}The option @option{--incremental} (@option{-G})
  4426. gives the same behavior as @option{--listed-incremental} when used
  4427. with @option{--list} and @option{--extract} options. When used with
  4428. @option{--create} option, it creates an incremental archive without
  4429. creating snapshot file. Thus, it is impossible to create several
  4430. levels of incremental backups with @option{--incremental} option.
  4431. @node Backup Levels
  4432. @section Levels of Backups
  4433. An archive containing all the files in the file system is called a
  4434. @dfn{full backup} or @dfn{full dump}. You could insure your data by
  4435. creating a full dump every day. This strategy, however, would waste a
  4436. substantial amount of archive media and user time, as unchanged files
  4437. are daily re-archived.
  4438. It is more efficient to do a full dump only occasionally. To back up
  4439. files between full dumps, you can use @dfn{incremental dumps}. A @dfn{level
  4440. one} dump archives all the files that have changed since the last full
  4441. dump.
  4442. A typical dump strategy would be to perform a full dump once a week,
  4443. and a level one dump once a day. This means some versions of files
  4444. will in fact be archived more than once, but this dump strategy makes
  4445. it possible to restore a file system to within one day of accuracy by
  4446. only extracting two archives---the last weekly (full) dump and the
  4447. last daily (level one) dump. The only information lost would be in
  4448. files changed or created since the last daily backup. (Doing dumps
  4449. more than once a day is usually not worth the trouble).
  4450. @GNUTAR{} comes with scripts you can use to do full
  4451. and level-one (actually, even level-two and so on) dumps. Using
  4452. scripts (shell programs) to perform backups and restoration is a
  4453. convenient and reliable alternative to typing out file name lists
  4454. and @command{tar} commands by hand.
  4455. Before you use these scripts, you need to edit the file
  4456. @file{backup-specs}, which specifies parameters used by the backup
  4457. scripts and by the restore script. This file is usually located
  4458. in @file{/etc/backup} directory. @xref{Backup Parameters}, for its
  4459. detailed description. Once the backup parameters are set, you can
  4460. perform backups or restoration by running the appropriate script.
  4461. The name of the backup script is @code{backup}. The name of the
  4462. restore script is @code{restore}. The following sections describe
  4463. their use in detail.
  4464. @emph{Please Note:} The backup and restoration scripts are
  4465. designed to be used together. While it is possible to restore files by
  4466. hand from an archive which was created using a backup script, and to create
  4467. an archive by hand which could then be extracted using the restore script,
  4468. it is easier to use the scripts. @xref{Incremental Dumps}, before
  4469. making such an attempt.
  4470. @node Backup Parameters
  4471. @section Setting Parameters for Backups and Restoration
  4472. The file @file{backup-specs} specifies backup parameters for the
  4473. backup and restoration scripts provided with @command{tar}. You must
  4474. edit @file{backup-specs} to fit your system configuration and schedule
  4475. before using these scripts.
  4476. Syntactically, @file{backup-specs} is a shell script, containing
  4477. mainly variable assignments. However, any valid shell construct
  4478. is allowed in this file. Particularly, you may wish to define
  4479. functions within that script (e.g., see @code{RESTORE_BEGIN} below).
  4480. For more information about shell script syntax, please refer to
  4481. @url{http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#ta
  4482. g_02, the definition of the Shell Command Language}. See also
  4483. @ref{Top,,Bash Features,bashref,Bash Reference Manual}.
  4484. The shell variables controlling behavior of @code{backup} and
  4485. @code{restore} are described in the following subsections.
  4486. @menu
  4487. * General-Purpose Variables::
  4488. * Magnetic Tape Control::
  4489. * User Hooks::
  4490. * backup-specs example:: An Example Text of @file{Backup-specs}
  4491. @end menu
  4492. @node General-Purpose Variables
  4493. @subsection General-Purpose Variables
  4494. @defvr {Backup variable} ADMINISTRATOR
  4495. The user name of the backup administrator. @code{Backup} scripts
  4496. sends a backup report to this address.
  4497. @end defvr
  4498. @defvr {Backup variable} BACKUP_HOUR
  4499. The hour at which the backups are done. This can be a number from 0
  4500. to 23, or the time specification in form @var{hours}:@var{minutes},
  4501. or the string @samp{now}.
  4502. This variable is used by @code{backup}. Its value may be overridden
  4503. using @option{--time} option (@pxref{Scripted Backups}).
  4504. @end defvr
  4505. @defvr {Backup variable} TAPE_FILE
  4506. The device @command{tar} writes the archive to. If @var{TAPE_FILE}
  4507. is a remote archive (@pxref{remote-dev}), backup script will suppose
  4508. that your @command{mt} is able to access remote devices. If @var{RSH}
  4509. (@pxref{RSH}) is set, @option{--rsh-command} option will be added to
  4510. invocations of @command{mt}.
  4511. @end defvr
  4512. @defvr {Backup variable} BLOCKING
  4513. The blocking factor @command{tar} will use when writing the dump archive.
  4514. @xref{Blocking Factor}.
  4515. @end defvr
  4516. @defvr {Backup variable} BACKUP_DIRS
  4517. A list of file systems to be dumped (for @code{backup}), or restored
  4518. (for @code{restore}). You can include any directory
  4519. name in the list --- subdirectories on that file system will be
  4520. included, regardless of how they may look to other networked machines.
  4521. Subdirectories on other file systems will be ignored.
  4522. The host name specifies which host to run @command{tar} on, and should
  4523. normally be the host that actually contains the file system. However,
  4524. the host machine must have @GNUTAR{} installed, and
  4525. must be able to access the directory containing the backup scripts and
  4526. their support files using the same file name that is used on the
  4527. machine where the scripts are run (i.e., what @command{pwd} will print
  4528. when in that directory on that machine). If the host that contains
  4529. the file system does not have this capability, you can specify another
  4530. host as long as it can access the file system through NFS.
  4531. If the list of file systems is very long you may wish to put it
  4532. in a separate file. This file is usually named
  4533. @file{/etc/backup/dirs}, but this name may be overridden in
  4534. @file{backup-specs} using @code{DIRLIST} variable.
  4535. @end defvr
  4536. @defvr {Backup variable} DIRLIST
  4537. The name of the file that contains a list of file systems to backup
  4538. or restore. By default it is @file{/etc/backup/dirs}.
  4539. @end defvr
  4540. @defvr {Backup variable} BACKUP_FILES
  4541. A list of individual files to be dumped (for @code{backup}), or restored
  4542. (for @code{restore}). These should be accessible from the machine on
  4543. which the backup script is run.
  4544. If the list of file systems is very long you may wish to store it
  4545. in a separate file. This file is usually named
  4546. @file{/etc/backup/files}, but this name may be overridden in
  4547. @file{backup-specs} using @code{FILELIST} variable.
  4548. @end defvr
  4549. @defvr {Backup variable} FILELIST
  4550. The name of the file that contains a list of individual files to backup
  4551. or restore. By default it is @file{/etc/backup/files}.
  4552. @end defvr
  4553. @defvr {Backup variable} MT
  4554. Full file name of @command{mt} binary.
  4555. @end defvr
  4556. @defvr {Backup variable} RSH
  4557. @anchor{RSH}
  4558. Full file name of @command{rsh} binary or its equivalent. You may wish to
  4559. set it to @code{ssh}, to improve security. In this case you will have
  4560. to use public key authentication.
  4561. @end defvr
  4562. @defvr {Backup variable} RSH_COMMAND
  4563. Full file name of @command{rsh} binary on remote machines. This will
  4564. be passed via @option{--rsh-command} option to the remote invocation
  4565. of @GNUTAR{}.
  4566. @end defvr
  4567. @defvr {Backup variable} VOLNO_FILE
  4568. Name of temporary file to hold volume numbers. This needs to be accessible
  4569. by all the machines which have file systems to be dumped.
  4570. @end defvr
  4571. @defvr {Backup variable} XLIST
  4572. Name of @dfn{exclude file list}. An @dfn{exclude file list} is a file
  4573. located on the remote machine and containing the list of files to
  4574. be excluded from the backup. Exclude file lists are searched in
  4575. /etc/tar-backup directory. A common use for exclude file lists
  4576. is to exclude files containing security-sensitive information
  4577. (e.g., @file{/etc/shadow} from backups).
  4578. This variable affects only @code{backup}.
  4579. @end defvr
  4580. @defvr {Backup variable} SLEEP_TIME
  4581. Time to sleep between dumps of any two successive file systems
  4582. This variable affects only @code{backup}.
  4583. @end defvr
  4584. @defvr {Backup variable} DUMP_REMIND_SCRIPT
  4585. Script to be run when it's time to insert a new tape in for the next
  4586. volume. Administrators may want to tailor this script for their site.
  4587. If this variable isn't set, @GNUTAR{} will display its built-in
  4588. prompt, and will expect confirmation from the console. For the
  4589. description of the default prompt, see @ref{change volume prompt}.
  4590. @end defvr
  4591. @defvr {Backup variable} SLEEP_MESSAGE
  4592. Message to display on the terminal while waiting for dump time. Usually
  4593. this will just be some literal text.
  4594. @end defvr
  4595. @defvr {Backup variable} TAR
  4596. Full file name of the @GNUTAR{} executable. If this is not set, backup
  4597. scripts will search @command{tar} in the current shell path.
  4598. @end defvr
  4599. @node Magnetic Tape Control
  4600. @subsection Magnetic Tape Control
  4601. Backup scripts access tape device using special @dfn{hook functions}.
  4602. These functions take a single argument -- the name of the tape
  4603. device. Their names are kept in the following variables:
  4604. @defvr {Backup variable} MT_BEGIN
  4605. The name of @dfn{begin} function. This function is called before
  4606. accessing the drive. By default it retensions the tape:
  4607. @smallexample
  4608. MT_BEGIN=mt_begin
  4609. mt_begin() @{
  4610. mt -f "$1" retension
  4611. @}
  4612. @end smallexample
  4613. @end defvr
  4614. @defvr {Backup variable} MT_REWIND
  4615. The name of @dfn{rewind} function. The default definition is as
  4616. follows:
  4617. @smallexample
  4618. MT_REWIND=mt_rewind
  4619. mt_rewind() @{
  4620. mt -f "$1" rewind
  4621. @}
  4622. @end smallexample
  4623. @end defvr
  4624. @defvr {Backup variable} MT_OFFLINE
  4625. The name of the function switching the tape off line. By default
  4626. it is defined as follows:
  4627. @smallexample
  4628. MT_OFFLINE=mt_offline
  4629. mt_offline() @{
  4630. mt -f "$1" offl
  4631. @}
  4632. @end smallexample
  4633. @end defvr
  4634. @defvr {Backup variable} MT_STATUS
  4635. The name of the function used to obtain the status of the archive device,
  4636. including error count. Default definition:
  4637. @smallexample
  4638. MT_STATUS=mt_status
  4639. mt_status() @{
  4640. mt -f "$1" status
  4641. @}
  4642. @end smallexample
  4643. @end defvr
  4644. @node User Hooks
  4645. @subsection User Hooks
  4646. @dfn{User hooks} are shell functions executed before and after
  4647. each @command{tar} invocation. Thus, there are @dfn{backup
  4648. hooks}, which are executed before and after dumping each file
  4649. system, and @dfn{restore hooks}, executed before and
  4650. after restoring a file system. Each user hook is a shell function
  4651. taking four arguments:
  4652. @deffn {User Hook Function} hook @var{level} @var{host} @var{fs} @var{fsname}
  4653. Its arguments are:
  4654. @table @var
  4655. @item level
  4656. Current backup or restore level.
  4657. @item host
  4658. Name or IP address of the host machine being dumped or restored.
  4659. @item fs
  4660. Full file name of the file system being dumped or restored.
  4661. @item fsname
  4662. File system name with directory separators replaced with colons. This
  4663. is useful, e.g., for creating unique files.
  4664. @end table
  4665. @end deffn
  4666. Following variables keep the names of user hook functions
  4667. @defvr {Backup variable} DUMP_BEGIN
  4668. Dump begin function. It is executed before dumping the file system.
  4669. @end defvr
  4670. @defvr {Backup variable} DUMP_END
  4671. Executed after dumping the file system.
  4672. @end defvr
  4673. @defvr {Backup variable} RESTORE_BEGIN
  4674. Executed before restoring the file system.
  4675. @end defvr
  4676. @defvr {Backup variable} RESTORE_END
  4677. Executed after restoring the file system.
  4678. @end defvr
  4679. @node backup-specs example
  4680. @subsection An Example Text of @file{Backup-specs}
  4681. The following is an example of @file{backup-specs}:
  4682. @smallexample
  4683. # site-specific parameters for file system backup.
  4684. ADMINISTRATOR=friedman
  4685. BACKUP_HOUR=1
  4686. TAPE_FILE=/dev/nrsmt0
  4687. # Use @code{ssh} instead of the less secure @code{rsh}
  4688. RSH=/usr/bin/ssh
  4689. RSH_COMMAND=/usr/bin/ssh
  4690. # Override MT_STATUS function:
  4691. my_status() @{
  4692. mts -t $TAPE_FILE
  4693. @}
  4694. MT_STATUS=my_status
  4695. # Disable MT_OFFLINE function
  4696. MT_OFFLINE=:
  4697. BLOCKING=124
  4698. BACKUP_DIRS="
  4699. albert:/fs/fsf
  4700. apple-gunkies:/gd
  4701. albert:/fs/gd2
  4702. albert:/fs/gp
  4703. geech:/usr/jla
  4704. churchy:/usr/roland
  4705. albert:/
  4706. albert:/usr
  4707. apple-gunkies:/
  4708. apple-gunkies:/usr
  4709. gnu:/hack
  4710. gnu:/u
  4711. apple-gunkies:/com/mailer/gnu
  4712. apple-gunkies:/com/archive/gnu"
  4713. BACKUP_FILES="/com/mailer/aliases /com/mailer/league*[a-z]"
  4714. @end smallexample
  4715. @node Scripted Backups
  4716. @section Using the Backup Scripts
  4717. The syntax for running a backup script is:
  4718. @smallexample
  4719. backup --level=@var{level} --time=@var{time}
  4720. @end smallexample
  4721. The @option{level} option requests the dump level. Thus, to produce
  4722. a full dump, specify @code{--level=0} (this is the default, so
  4723. @option{--level} may be omitted if its value is @code{0}).
  4724. @footnote{For backward compatibility, the @code{backup} will also
  4725. try to deduce the requested dump level from the name of the
  4726. script itself. If the name consists of a string @samp{level-}
  4727. followed by a single decimal digit, that digit is taken as
  4728. the dump level number. Thus, you may create a link from @code{backup}
  4729. to @code{level-1} and then run @code{level-1} whenever you need to
  4730. create a level one dump.}
  4731. The @option{--time} option determines when should the backup be
  4732. run. @var{Time} may take three forms:
  4733. @table @asis
  4734. @item @var{hh}:@var{mm}
  4735. The dump must be run at @var{hh} hours @var{mm} minutes.
  4736. @item @var{hh}
  4737. The dump must be run at @var{hh} hours
  4738. @item now
  4739. The dump must be run immediately.
  4740. @end table
  4741. You should start a script with a tape or disk mounted. Once you
  4742. start a script, it prompts you for new tapes or disks as it
  4743. needs them. Media volumes don't have to correspond to archive
  4744. files --- a multi-volume archive can be started in the middle of a
  4745. tape that already contains the end of another multi-volume archive.
  4746. The @code{restore} script prompts for media by its archive volume,
  4747. so to avoid an error message you should keep track of which tape
  4748. (or disk) contains which volume of the archive (@pxref{Scripted
  4749. Restoration}).
  4750. The backup scripts write two files on the file system. The first is a
  4751. record file in @file{/etc/tar-backup/}, which is used by the scripts
  4752. to store and retrieve information about which files were dumped. This
  4753. file is not meant to be read by humans, and should not be deleted by
  4754. them. @xref{Snapshot Files}, for a more detailed explanation of this
  4755. file.
  4756. The second file is a log file containing the names of the file systems
  4757. and files dumped, what time the backup was made, and any error
  4758. messages that were generated, as well as how much space was left in
  4759. the media volume after the last volume of the archive was written.
  4760. You should check this log file after every backup. The file name is
  4761. @file{log-@var{mm-dd-yyyy}-level-@var{n}}, where @var{mm-dd-yyyy}
  4762. represents current date, and @var{n} represents current dump level number.
  4763. The script also prints the name of each system being dumped to the
  4764. standard output.
  4765. Following is the full list of options accepted by @code{backup}
  4766. script:
  4767. @table @option
  4768. @item -l @var{level}
  4769. @itemx --level=@var{level}
  4770. Do backup level @var{level} (default 0).
  4771. @item -f
  4772. @itemx --force
  4773. Force backup even if today's log file already exists.
  4774. @item -v[@var{level}]
  4775. @itemx --verbose[=@var{level}]
  4776. Set verbosity level. The higher the level is, the more debugging
  4777. information will be output during execution. Default @var{level}
  4778. is 100, which means the highest debugging level.
  4779. @item -t @var{start-time}
  4780. @itemx --time=@var{start-time}
  4781. Wait till @var{time}, then do backup.
  4782. @item -h
  4783. @itemx --help
  4784. Display short help message and exit.
  4785. @item -V
  4786. @itemx --version
  4787. Display information about the program's name, version, origin and legal
  4788. status, all on standard output, and then exit successfully.
  4789. @end table
  4790. @node Scripted Restoration
  4791. @section Using the Restore Script
  4792. To restore files that were archived using a scripted backup, use the
  4793. @code{restore} script. Its usage is quite straightforward. In the
  4794. simplest form, invoke @code{restore --all}, it will
  4795. then restore all the file systems and files specified in
  4796. @file{backup-specs} (@pxref{General-Purpose Variables,BACKUP_DIRS}).
  4797. You may select the file systems (and/or files) to restore by
  4798. giving @code{restore} list of @dfn{patterns} in its command
  4799. line. For example, running
  4800. @smallexample
  4801. restore 'albert:*'
  4802. @end smallexample
  4803. @noindent
  4804. will restore all file systems on the machine @samp{albert}. A more
  4805. complicated example:
  4806. @smallexample
  4807. restore 'albert:*' '*:/var'
  4808. @end smallexample
  4809. @noindent
  4810. This command will restore all file systems on the machine @samp{albert}
  4811. as well as @file{/var} file system on all machines.
  4812. By default @code{restore} will start restoring files from the lowest
  4813. available dump level (usually zero) and will continue through
  4814. all available dump levels. There may be situations where such a
  4815. thorough restore is not necessary. For example, you may wish to
  4816. restore only files from the recent level one backup. To do so,
  4817. use @option{--level} option, as shown in the example below:
  4818. @smallexample
  4819. restore --level=1
  4820. @end smallexample
  4821. The full list of options accepted by @code{restore} follows:
  4822. @table @option
  4823. @item -a
  4824. @itemx --all
  4825. Restore all file systems and files specified in @file{backup-specs}
  4826. @item -l @var{level}
  4827. @itemx --level=@var{level}
  4828. Start restoring from the given backup level, instead of the default 0.
  4829. @item -v[@var{level}]
  4830. @itemx --verbose[=@var{level}]
  4831. Set verbosity level. The higher the level is, the more debugging
  4832. information will be output during execution. Default @var{level}
  4833. is 100, which means the highest debugging level.
  4834. @item -h
  4835. @itemx --help
  4836. Display short help message and exit.
  4837. @item -V
  4838. @itemx --version
  4839. Display information about the program's name, version, origin and legal
  4840. status, all on standard output, and then exit successfully.
  4841. @end table
  4842. You should start the restore script with the media containing the
  4843. first volume of the archive mounted. The script will prompt for other
  4844. volumes as they are needed. If the archive is on tape, you don't need
  4845. to rewind the tape to to its beginning---if the tape head is
  4846. positioned past the beginning of the archive, the script will rewind
  4847. the tape as needed. @xref{Tape Positioning}, for a discussion of tape
  4848. positioning.
  4849. @quotation
  4850. @strong{Warning:} The script will delete files from the active file
  4851. system if they were not in the file system when the archive was made.
  4852. @end quotation
  4853. @xref{Incremental Dumps}, for an explanation of how the script makes
  4854. that determination.
  4855. @node Choosing
  4856. @chapter Choosing Files and Names for @command{tar}
  4857. @UNREVISED
  4858. Certain options to @command{tar} enable you to specify a name for your
  4859. archive. Other options let you decide which files to include or exclude
  4860. from the archive, based on when or whether files were modified, whether
  4861. the file names do or don't match specified patterns, or whether files
  4862. are in specified directories.
  4863. This chapter discusses these options in detail.
  4864. @menu
  4865. * file:: Choosing the Archive's Name
  4866. * Selecting Archive Members::
  4867. * files:: Reading Names from a File
  4868. * exclude:: Excluding Some Files
  4869. * wildcards:: Wildcards Patterns and Matching
  4870. * quoting styles:: Ways of Quoting Special Characters in Names
  4871. * transform:: Modifying File and Member Names
  4872. * after:: Operating Only on New Files
  4873. * recurse:: Descending into Directories
  4874. * one:: Crossing File System Boundaries
  4875. @end menu
  4876. @node file
  4877. @section Choosing and Naming Archive Files
  4878. @UNREVISED
  4879. @cindex Naming an archive
  4880. @cindex Archive Name
  4881. @cindex Choosing an archive file
  4882. @cindex Where is the archive?
  4883. By default, @command{tar} uses an archive file name that was compiled when
  4884. it was built on the system; usually this name refers to some physical
  4885. tape drive on the machine. However, the person who installed @command{tar}
  4886. on the system may not have set the default to a meaningful value as far as
  4887. most users are concerned. As a result, you will usually want to tell
  4888. @command{tar} where to find (or create) the archive. The
  4889. @option{--file=@var{archive-name}} (@option{-f @var{archive-name}})
  4890. option allows you to either specify or name a file to use as the archive
  4891. instead of the default archive file location.
  4892. @table @option
  4893. @xopindex{file, short description}
  4894. @item --file=@var{archive-name}
  4895. @itemx -f @var{archive-name}
  4896. Name the archive to create or operate on. Use in conjunction with
  4897. any operation.
  4898. @end table
  4899. For example, in this @command{tar} command,
  4900. @smallexample
  4901. $ @kbd{tar -cvf collection.tar blues folk jazz}
  4902. @end smallexample
  4903. @noindent
  4904. @file{collection.tar} is the name of the archive. It must directly
  4905. follow the @option{-f} option, since whatever directly follows @option{-f}
  4906. @emph{will} end up naming the archive. If you neglect to specify an
  4907. archive name, you may end up overwriting a file in the working directory
  4908. with the archive you create since @command{tar} will use this file's name
  4909. for the archive name.
  4910. An archive can be saved as a file in the file system, sent through a
  4911. pipe or over a network, or written to an I/O device such as a tape,
  4912. floppy disk, or CD write drive.
  4913. @cindex Writing new archives
  4914. @cindex Archive creation
  4915. If you do not name the archive, @command{tar} uses the value of the
  4916. environment variable @env{TAPE} as the file name for the archive. If
  4917. that is not available, @command{tar} uses a default, compiled-in archive
  4918. name, usually that for tape unit zero (i.e., @file{/dev/tu00}).
  4919. @cindex Standard input and output
  4920. @cindex tar to standard input and output
  4921. If you use @file{-} as an @var{archive-name}, @command{tar} reads the
  4922. archive from standard input (when listing or extracting files), or
  4923. writes it to standard output (when creating an archive). If you use
  4924. @file{-} as an @var{archive-name} when modifying an archive,
  4925. @command{tar} reads the original archive from its standard input and
  4926. writes the entire new archive to its standard output.
  4927. The following example is a convenient way of copying directory
  4928. hierarchy from @file{sourcedir} to @file{targetdir}.
  4929. @smallexample
  4930. $ @kbd{(cd sourcedir; tar -cf - .) | (cd targetdir; tar -xpf -)}
  4931. @end smallexample
  4932. The @option{-C} option allows to avoid using subshells:
  4933. @smallexample
  4934. $ @kbd{tar -C sourcedir -cf - . | tar -C targetdir -xpf -}
  4935. @end smallexample
  4936. In both examples above, the leftmost @command{tar} invocation archives
  4937. the contents of @file{sourcedir} to the standard output, while the
  4938. rightmost one reads this archive from its standard input and
  4939. extracts it. The @option{-p} option tells it to restore permissions
  4940. of the extracted files.
  4941. @cindex Remote devices
  4942. @cindex tar to a remote device
  4943. @anchor{remote-dev}
  4944. To specify an archive file on a device attached to a remote machine,
  4945. use the following:
  4946. @smallexample
  4947. @kbd{--file=@var{hostname}:/@var{dev}/@var{file-name}}
  4948. @end smallexample
  4949. @noindent
  4950. @command{tar} will complete the remote connection, if possible, and
  4951. prompt you for a username and password. If you use
  4952. @option{--file=@@@var{hostname}:/@var{dev}/@var{file-name}}, @command{tar}
  4953. will complete the remote connection, if possible, using your username
  4954. as the username on the remote machine.
  4955. @cindex Local and remote archives
  4956. @anchor{local and remote archives}
  4957. If the archive file name includes a colon (@samp{:}), then it is assumed
  4958. to be a file on another machine. If the archive file is
  4959. @samp{@var{user}@@@var{host}:@var{file}}, then @var{file} is used on the
  4960. host @var{host}. The remote host is accessed using the @command{rsh}
  4961. program, with a username of @var{user}. If the username is omitted
  4962. (along with the @samp{@@} sign), then your user name will be used.
  4963. (This is the normal @command{rsh} behavior.) It is necessary for the
  4964. remote machine, in addition to permitting your @command{rsh} access, to
  4965. have the @file{rmt} program installed (This command is included in
  4966. the @GNUTAR{} distribution and by default is installed under
  4967. @file{@var{prefix}/libexec/rmt}, were @var{prefix} means your
  4968. installation prefix). If you need to use a file whose name includes a
  4969. colon, then the remote tape drive behavior
  4970. can be inhibited by using the @option{--force-local} option.
  4971. When the archive is being created to @file{/dev/null}, @GNUTAR{}
  4972. tries to minimize input and output operations. The Amanda backup
  4973. system, when used with @GNUTAR{}, has an initial sizing pass which
  4974. uses this feature.
  4975. @node Selecting Archive Members
  4976. @section Selecting Archive Members
  4977. @cindex Specifying files to act on
  4978. @cindex Specifying archive members
  4979. @dfn{File Name arguments} specify which files in the file system
  4980. @command{tar} operates on, when creating or adding to an archive, or which
  4981. archive members @command{tar} operates on, when reading or deleting from
  4982. an archive. @xref{Operations}.
  4983. To specify file names, you can include them as the last arguments on
  4984. the command line, as follows:
  4985. @smallexample
  4986. @kbd{tar} @var{operation} [@var{option1} @var{option2} @dots{}] [@var{file name-1} @var{file name-2} @dots{}]
  4987. @end smallexample
  4988. If a file name begins with dash (@samp{-}), precede it with
  4989. @option{--add-file} option to prevent it from being treated as an
  4990. option.
  4991. @anchor{input name quoting}
  4992. By default @GNUTAR{} attempts to @dfn{unquote} each file or member
  4993. name, replacing @dfn{escape sequences} according to the following
  4994. table:
  4995. @multitable @columnfractions 0.20 0.60
  4996. @headitem Escape @tab Replaced with
  4997. @item \a @tab Audible bell (@acronym{ASCII} 7)
  4998. @item \b @tab Backspace (@acronym{ASCII} 8)
  4999. @item \f @tab Form feed (@acronym{ASCII} 12)
  5000. @item \n @tab New line (@acronym{ASCII} 10)
  5001. @item \r @tab Carriage return (@acronym{ASCII} 13)
  5002. @item \t @tab Horizontal tabulation (@acronym{ASCII} 9)
  5003. @item \v @tab Vertical tabulation (@acronym{ASCII} 11)
  5004. @item \? @tab @acronym{ASCII} 127
  5005. @item \@var{n} @tab @acronym{ASCII} @var{n} (@var{n} should be an octal number
  5006. of up to 3 digits)
  5007. @end multitable
  5008. A backslash followed by any other symbol is retained.
  5009. This default behavior is controlled by the following command line
  5010. option:
  5011. @table @option
  5012. @opindex unquote
  5013. @item --unquote
  5014. Enable unquoting input file or member names (default).
  5015. @opindex no-unquote
  5016. @item --no-unquote
  5017. Disable unquoting input file or member names.
  5018. @end table
  5019. If you specify a directory name as a file name argument, all the files
  5020. in that directory are operated on by @command{tar}.
  5021. If you do not specify files, @command{tar} behavior differs depending
  5022. on the operation mode as described below:
  5023. When @command{tar} is invoked with @option{--create} (@option{-c}),
  5024. @command{tar} will stop immediately, reporting the following:
  5025. @smallexample
  5026. @group
  5027. $ @kbd{tar cf a.tar}
  5028. tar: Cowardly refusing to create an empty archive
  5029. Try `tar --help' or `tar --usage' for more information.
  5030. @end group
  5031. @end smallexample
  5032. If you specify either @option{--list} (@option{-t}) or
  5033. @option{--extract} (@option{--get}, @option{-x}), @command{tar}
  5034. operates on all the archive members in the archive.
  5035. If run with @option{--diff} option, tar will compare the archive with
  5036. the contents of the current working directory.
  5037. If you specify any other operation, @command{tar} does nothing.
  5038. By default, @command{tar} takes file names from the command line. However,
  5039. there are other ways to specify file or member names, or to modify the
  5040. manner in which @command{tar} selects the files or members upon which to
  5041. operate. In general, these methods work both for specifying the names
  5042. of files and archive members.
  5043. @node files
  5044. @section Reading Names from a File
  5045. @cindex Reading file names from a file
  5046. @cindex Lists of file names
  5047. @cindex File Name arguments, alternatives
  5048. Instead of giving the names of files or archive members on the command
  5049. line, you can put the names into a file, and then use the
  5050. @option{--files-from=@var{file-of-names}} (@option{-T
  5051. @var{file-of-names}}) option to @command{tar}. Give the name of the
  5052. file which contains the list of files to include as the argument to
  5053. @option{--files-from}. In the list, the file names should be separated by
  5054. newlines. You will frequently use this option when you have generated
  5055. the list of files to archive with the @command{find} utility.
  5056. @table @option
  5057. @opindex files-from
  5058. @item --files-from=@var{file-name}
  5059. @itemx -T @var{file-name}
  5060. Get names to extract or create from file @var{file-name}.
  5061. @end table
  5062. If you give a single dash as a file name for @option{--files-from}, (i.e.,
  5063. you specify either @code{--files-from=-} or @code{-T -}), then the file
  5064. names are read from standard input.
  5065. Unless you are running @command{tar} with @option{--create}, you can not use
  5066. both @code{--files-from=-} and @code{--file=-} (@code{-f -}) in the same
  5067. command.
  5068. Any number of @option{-T} options can be given in the command line.
  5069. The following example shows how to use @command{find} to generate a list of
  5070. files smaller than 400K in length and put that list into a file
  5071. called @file{small-files}. You can then use the @option{-T} option to
  5072. @command{tar} to specify the files from that file, @file{small-files}, to
  5073. create the archive @file{little.tgz}. (The @option{-z} option to
  5074. @command{tar} compresses the archive with @command{gzip}; @pxref{gzip} for
  5075. more information.)
  5076. @smallexample
  5077. $ @kbd{find . -size -400 -print > small-files}
  5078. $ @kbd{tar -c -v -z -T small-files -f little.tgz}
  5079. @end smallexample
  5080. @noindent
  5081. In the file list given by @option{-T} option, any file name beginning
  5082. with @samp{-} character is considered a @command{tar} option and is
  5083. processed accordingly.@footnote{Versions of @GNUTAR{} up to 1.15.1
  5084. recognized only @option{-C} option in file lists, and only if the
  5085. option and its argument occupied two consecutive lines.} For example,
  5086. the common use of this feature is to change to another directory by
  5087. specifying @option{-C} option:
  5088. @smallexample
  5089. @group
  5090. $ @kbd{cat list}
  5091. -C/etc
  5092. passwd
  5093. hosts
  5094. -C/lib
  5095. libc.a
  5096. $ @kbd{tar -c -f foo.tar --files-from list}
  5097. @end group
  5098. @end smallexample
  5099. @noindent
  5100. In this example, @command{tar} will first switch to @file{/etc}
  5101. directory and add files @file{passwd} and @file{hosts} to the
  5102. archive. Then it will change to @file{/lib} directory and will archive
  5103. the file @file{libc.a}. Thus, the resulting archive @file{foo.tar} will
  5104. contain:
  5105. @smallexample
  5106. @group
  5107. $ @kbd{tar tf foo.tar}
  5108. passwd
  5109. hosts
  5110. libc.a
  5111. @end group
  5112. @end smallexample
  5113. @noindent
  5114. @xopindex{directory, using in @option{--files-from} argument}
  5115. Notice that the option parsing algorithm used with @option{-T} is
  5116. stricter than the one used by shell. Namely, when specifying option
  5117. arguments, you should observe the following rules:
  5118. @itemize @bullet
  5119. @item
  5120. When using short (single-letter) option form, its argument must
  5121. immediately follow the option letter, without any intervening
  5122. whitespace. For example: @code{-Cdir}.
  5123. @item
  5124. When using long option form, the option argument must be separated
  5125. from the option by a single equal sign. No whitespace is allowed on
  5126. any side of the equal sign. For example: @code{--directory=dir}.
  5127. @item
  5128. For both short and long option forms, the option argument can be given
  5129. on the next line after the option name, e.g.:
  5130. @smallexample
  5131. @group
  5132. --directory
  5133. dir
  5134. @end group
  5135. @end smallexample
  5136. @noindent
  5137. and
  5138. @smallexample
  5139. @group
  5140. -C
  5141. dir
  5142. @end group
  5143. @end smallexample
  5144. @end itemize
  5145. @opindex add-file
  5146. If you happen to have a file whose name starts with @samp{-},
  5147. precede it with @option{--add-file} option to prevent it from
  5148. being recognized as an option. For example: @code{--add-file=--my-file}.
  5149. @menu
  5150. * nul::
  5151. @end menu
  5152. @node nul
  5153. @subsection @code{NUL} Terminated File Names
  5154. @cindex File names, terminated by @code{NUL}
  5155. @cindex @code{NUL} terminated file names
  5156. The @option{--null} option causes
  5157. @option{--files-from=@var{file-of-names}} (@option{-T @var{file-of-names}})
  5158. to read file names terminated by a @code{NUL} instead of a newline, so
  5159. files whose names contain newlines can be archived using
  5160. @option{--files-from}.
  5161. @table @option
  5162. @opindex null
  5163. @item --null
  5164. Only consider @code{NUL} terminated file names, instead of files that
  5165. terminate in a newline.
  5166. @end table
  5167. The @option{--null} option is just like the one in @acronym{GNU}
  5168. @command{xargs} and @command{cpio}, and is useful with the
  5169. @option{-print0} predicate of @acronym{GNU} @command{find}. In
  5170. @command{tar}, @option{--null} also disables special handling for
  5171. file names that begin with dash.
  5172. This example shows how to use @command{find} to generate a list of files
  5173. larger than 800K in length and put that list into a file called
  5174. @file{long-files}. The @option{-print0} option to @command{find} is just
  5175. like @option{-print}, except that it separates files with a @code{NUL}
  5176. rather than with a newline. You can then run @command{tar} with both the
  5177. @option{--null} and @option{-T} options to specify that @command{tar} get the
  5178. files from that file, @file{long-files}, to create the archive
  5179. @file{big.tgz}. The @option{--null} option to @command{tar} will cause
  5180. @command{tar} to recognize the @code{NUL} separator between files.
  5181. @smallexample
  5182. $ @kbd{find . -size +800 -print0 > long-files}
  5183. $ @kbd{tar -c -v --null --files-from=long-files --file=big.tar}
  5184. @end smallexample
  5185. @FIXME{say anything else here to conclude the section?}
  5186. @node exclude
  5187. @section Excluding Some Files
  5188. @UNREVISED
  5189. @cindex File names, excluding files by
  5190. @cindex Excluding files by name and pattern
  5191. @cindex Excluding files by file system
  5192. To avoid operating on files whose names match a particular pattern,
  5193. use the @option{--exclude} or @option{--exclude-from} options.
  5194. @table @option
  5195. @opindex exclude
  5196. @item --exclude=@var{pattern}
  5197. Causes @command{tar} to ignore files that match the @var{pattern}.
  5198. @end table
  5199. @findex exclude
  5200. The @option{--exclude=@var{pattern}} option prevents any file or
  5201. member whose name matches the shell wildcard (@var{pattern}) from
  5202. being operated on.
  5203. For example, to create an archive with all the contents of the directory
  5204. @file{src} except for files whose names end in @file{.o}, use the
  5205. command @samp{tar -cf src.tar --exclude='*.o' src}.
  5206. You may give multiple @option{--exclude} options.
  5207. @table @option
  5208. @opindex exclude-from
  5209. @item --exclude-from=@var{file}
  5210. @itemx -X @var{file}
  5211. Causes @command{tar} to ignore files that match the patterns listed in
  5212. @var{file}.
  5213. @end table
  5214. @findex exclude-from
  5215. Use the @option{--exclude-from} option to read a
  5216. list of patterns, one per line, from @var{file}; @command{tar} will
  5217. ignore files matching those patterns. Thus if @command{tar} is
  5218. called as @w{@samp{tar -c -X foo .}} and the file @file{foo} contains a
  5219. single line @file{*.o}, no files whose names end in @file{.o} will be
  5220. added to the archive.
  5221. @findex exclude-caches
  5222. When creating an archive, the @option{--exclude-caches} option family
  5223. causes @command{tar} to exclude all directories that contain a @dfn{cache
  5224. directory tag}. A cache directory tag is a short file with the
  5225. well-known name @file{CACHEDIR.TAG} and having a standard header
  5226. specified in @url{http://www.brynosaurus.com/cachedir/spec.html}.
  5227. Various applications write cache directory tags into directories they
  5228. use to hold regenerable, non-precious data, so that such data can be
  5229. more easily excluded from backups.
  5230. There are three @samp{exclude-caches} option, providing a different
  5231. exclusion semantics:
  5232. @table @option
  5233. @opindex exclude-caches
  5234. @item --exclude-caches
  5235. Do not archive the contents of the directory, but archive the
  5236. directory itself and the @file{CACHEDIR.TAG} file.
  5237. @opindex exclude-caches-under
  5238. @item --exclude-caches-under
  5239. Do not archive the contents of the directory, nor the
  5240. @file{CACHEDIR.TAG} file, archive only the directory itself.
  5241. @opindex exclude-caches-all
  5242. @item --exclude-caches-all
  5243. Omit directories containing @file{CACHEDIR.TAG} file entirely.
  5244. @end table
  5245. @findex exclude-tag
  5246. Another option family, @option{--exclude-tag}, provides a generalization of
  5247. this concept. It takes a single argument, a file name to look for.
  5248. Any directory that contains this file will be excluded from the dump.
  5249. Similarly to @samp{exclude-caches}, there are three options in this
  5250. option family:
  5251. @table @option
  5252. @opindex exclude-tag
  5253. @item --exclude-tag=@var{file}
  5254. Do not dump the contents of the directory, but dump the
  5255. directory itself and the @var{file}.
  5256. @opindex exclude-tag-under
  5257. @item --exclude-tag-under=@var{file}
  5258. Do not dump the contents of the directory, nor the
  5259. @var{file}, archive only the directory itself.
  5260. @opindex exclude-tag-all
  5261. @item --exclude-tag-all=@var{file}
  5262. Omit directories containing @var{file} file entirely.
  5263. @end table
  5264. Multiple @option{--exclude-tag*} options can be given.
  5265. For example, given this directory:
  5266. @smallexample
  5267. @group
  5268. $ @kbd{find dir}
  5269. dir
  5270. dir/blues
  5271. dir/jazz
  5272. dir/folk
  5273. dir/folk/tagfile
  5274. dir/folk/sanjuan
  5275. dir/folk/trote
  5276. @end group
  5277. @end smallexample
  5278. The @option{--exclude-tag} will produce the following:
  5279. @smallexample
  5280. $ @kbd{tar -cf archive.tar --exclude-tag=tagfile -v dir}
  5281. dir/
  5282. dir/blues
  5283. dir/jazz
  5284. dir/folk/
  5285. tar: dir/folk/: contains a cache directory tag tagfile;
  5286. contents not dumped
  5287. dir/folk/tagfile
  5288. @end smallexample
  5289. Both the @file{dir/folk} directory and its tagfile are preserved in
  5290. the archive, however the rest of files in this directory are not.
  5291. Now, using the @option{--exclude-tag-under} option will exclude
  5292. @file{tagfile} from the dump, while still preserving the directory
  5293. itself, as shown in this example:
  5294. @smallexample
  5295. $ @kbd{tar -cf archive.tar --exclude-tag-under=tagfile -v dir}
  5296. dir/
  5297. dir/blues
  5298. dir/jazz
  5299. dir/folk/
  5300. ./tar: dir/folk/: contains a cache directory tag tagfile;
  5301. contents not dumped
  5302. @end smallexample
  5303. Finally, using @option{--exclude-tag-all} omits the @file{dir/folk}
  5304. directory entirely:
  5305. @smallexample
  5306. $ @kbd{tar -cf archive.tar --exclude-tag-all=tagfile -v dir}
  5307. dir/
  5308. dir/blues
  5309. dir/jazz
  5310. ./tar: dir/folk/: contains a cache directory tag tagfile;
  5311. directory not dumped
  5312. @end smallexample
  5313. @menu
  5314. * problems with exclude::
  5315. @end menu
  5316. @node problems with exclude
  5317. @unnumberedsubsec Problems with Using the @code{exclude} Options
  5318. @xopindex{exclude, potential problems with}
  5319. Some users find @samp{exclude} options confusing. Here are some common
  5320. pitfalls:
  5321. @itemize @bullet
  5322. @item
  5323. The main operating mode of @command{tar} does not act on a file name
  5324. explicitly listed on the command line, if one of its file name
  5325. components is excluded. In the example above, if
  5326. you create an archive and exclude files that end with @samp{*.o}, but
  5327. explicitly name the file @samp{dir.o/foo} after all the options have been
  5328. listed, @samp{dir.o/foo} will be excluded from the archive.
  5329. @item
  5330. You can sometimes confuse the meanings of @option{--exclude} and
  5331. @option{--exclude-from}. Be careful: use @option{--exclude} when files
  5332. to be excluded are given as a pattern on the command line. Use
  5333. @option{--exclude-from} to introduce the name of a file which contains
  5334. a list of patterns, one per line; each of these patterns can exclude
  5335. zero, one, or many files.
  5336. @item
  5337. When you use @option{--exclude=@var{pattern}}, be sure to quote the
  5338. @var{pattern} parameter, so @GNUTAR{} sees wildcard characters
  5339. like @samp{*}. If you do not do this, the shell might expand the
  5340. @samp{*} itself using files at hand, so @command{tar} might receive a
  5341. list of files instead of one pattern, or none at all, making the
  5342. command somewhat illegal. This might not correspond to what you want.
  5343. For example, write:
  5344. @smallexample
  5345. $ @kbd{tar -c -f @var{archive.tar} --exclude '*.o' @var{directory}}
  5346. @end smallexample
  5347. @noindent
  5348. rather than:
  5349. @smallexample
  5350. # @emph{Wrong!}
  5351. $ @kbd{tar -c -f @var{archive.tar} --exclude *.o @var{directory}}
  5352. @end smallexample
  5353. @item
  5354. You must use use shell syntax, or globbing, rather than @code{regexp}
  5355. syntax, when using exclude options in @command{tar}. If you try to use
  5356. @code{regexp} syntax to describe files to be excluded, your command
  5357. might fail.
  5358. @item
  5359. @FIXME{The change in semantics must have occurred before 1.11,
  5360. so I doubt if it is worth mentioning at all. Anyway, should at
  5361. least specify in which version the semantics changed.}
  5362. In earlier versions of @command{tar}, what is now the
  5363. @option{--exclude-from} option was called @option{--exclude} instead.
  5364. Now, @option{--exclude} applies to patterns listed on the command
  5365. line and @option{--exclude-from} applies to patterns listed in a
  5366. file.
  5367. @end itemize
  5368. @node wildcards
  5369. @section Wildcards Patterns and Matching
  5370. @dfn{Globbing} is the operation by which @dfn{wildcard} characters,
  5371. @samp{*} or @samp{?} for example, are replaced and expanded into all
  5372. existing files matching the given pattern. @GNUTAR{} can use wildcard
  5373. patterns for matching (or globbing) archive members when extracting
  5374. from or listing an archive. Wildcard patterns are also used for
  5375. verifying volume labels of @command{tar} archives. This section has the
  5376. purpose of explaining wildcard syntax for @command{tar}.
  5377. @FIXME{the next few paragraphs need work.}
  5378. A @var{pattern} should be written according to shell syntax, using wildcard
  5379. characters to effect globbing. Most characters in the pattern stand
  5380. for themselves in the matched string, and case is significant: @samp{a}
  5381. will match only @samp{a}, and not @samp{A}. The character @samp{?} in the
  5382. pattern matches any single character in the matched string. The character
  5383. @samp{*} in the pattern matches zero, one, or more single characters in
  5384. the matched string. The character @samp{\} says to take the following
  5385. character of the pattern @emph{literally}; it is useful when one needs to
  5386. match the @samp{?}, @samp{*}, @samp{[} or @samp{\} characters, themselves.
  5387. The character @samp{[}, up to the matching @samp{]}, introduces a character
  5388. class. A @dfn{character class} is a list of acceptable characters
  5389. for the next single character of the matched string. For example,
  5390. @samp{[abcde]} would match any of the first five letters of the alphabet.
  5391. Note that within a character class, all of the ``special characters''
  5392. listed above other than @samp{\} lose their special meaning; for example,
  5393. @samp{[-\\[*?]]} would match any of the characters, @samp{-}, @samp{\},
  5394. @samp{[}, @samp{*}, @samp{?}, or @samp{]}. (Due to parsing constraints,
  5395. the characters @samp{-} and @samp{]} must either come @emph{first} or
  5396. @emph{last} in a character class.)
  5397. @cindex Excluding characters from a character class
  5398. @cindex Character class, excluding characters from
  5399. If the first character of the class after the opening @samp{[}
  5400. is @samp{!} or @samp{^}, then the meaning of the class is reversed.
  5401. Rather than listing character to match, it lists those characters which
  5402. are @emph{forbidden} as the next single character of the matched string.
  5403. Other characters of the class stand for themselves. The special
  5404. construction @samp{[@var{a}-@var{e}]}, using an hyphen between two
  5405. letters, is meant to represent all characters between @var{a} and
  5406. @var{e}, inclusive.
  5407. @FIXME{need to add a sentence or so here to make this clear for those
  5408. who don't have dan around.}
  5409. Periods (@samp{.}) or forward slashes (@samp{/}) are not considered
  5410. special for wildcard matches. However, if a pattern completely matches
  5411. a directory prefix of a matched string, then it matches the full matched
  5412. string: thus, excluding a directory also excludes all the files beneath it.
  5413. @menu
  5414. * controlling pattern-matching::
  5415. @end menu
  5416. @node controlling pattern-matching
  5417. @unnumberedsubsec Controlling Pattern-Matching
  5418. For the purposes of this section, we call @dfn{exclusion members} all
  5419. member names obtained while processing @option{--exclude} and
  5420. @option{--exclude-from} options, and @dfn{inclusion members} those
  5421. member names that were given in the command line or read from the file
  5422. specified with @option{--files-from} option.
  5423. These two pairs of member lists are used in the following operations:
  5424. @option{--diff}, @option{--extract}, @option{--list},
  5425. @option{--update}.
  5426. There are no inclusion members in create mode (@option{--create} and
  5427. @option{--append}), since in this mode the names obtained from the
  5428. command line refer to @emph{files}, not archive members.
  5429. By default, inclusion members are compared with archive members
  5430. literally @footnote{Notice that earlier @GNUTAR{} versions used
  5431. globbing for inclusion members, which contradicted to UNIX98
  5432. specification and was not documented. @xref{Changes}, for more
  5433. information on this and other changes.} and exclusion members are
  5434. treated as globbing patterns. For example:
  5435. @smallexample
  5436. @group
  5437. $ @kbd{tar tf foo.tar}
  5438. a.c
  5439. b.c
  5440. a.txt
  5441. [remarks]
  5442. # @i{Member names are used verbatim:}
  5443. $ @kbd{tar -xf foo.tar -v '[remarks]'}
  5444. [remarks]
  5445. # @i{Exclude member names are globbed:}
  5446. $ @kbd{tar -xf foo.tar -v --exclude '*.c'}
  5447. a.txt
  5448. [remarks]
  5449. @end group
  5450. @end smallexample
  5451. This behavior can be altered by using the following options:
  5452. @table @option
  5453. @opindex wildcards
  5454. @item --wildcards
  5455. Treat all member names as wildcards.
  5456. @opindex no-wildcards
  5457. @item --no-wildcards
  5458. Treat all member names as literal strings.
  5459. @end table
  5460. Thus, to extract files whose names end in @samp{.c}, you can use:
  5461. @smallexample
  5462. $ @kbd{tar -xf foo.tar -v --wildcards '*.c'}
  5463. a.c
  5464. b.c
  5465. @end smallexample
  5466. @noindent
  5467. Notice quoting of the pattern to prevent the shell from interpreting
  5468. it.
  5469. The effect of @option{--wildcards} option is canceled by
  5470. @option{--no-wildcards}. This can be used to pass part of
  5471. the command line arguments verbatim and other part as globbing
  5472. patterns. For example, the following invocation:
  5473. @smallexample
  5474. $ @kbd{tar -xf foo.tar --wildcards '*.txt' --no-wildcards '[remarks]'}
  5475. @end smallexample
  5476. @noindent
  5477. instructs @command{tar} to extract from @file{foo.tar} all files whose
  5478. names end in @samp{.txt} and the file named @file{[remarks]}.
  5479. Normally, a pattern matches a name if an initial subsequence of the
  5480. name's components matches the pattern, where @samp{*}, @samp{?}, and
  5481. @samp{[...]} are the usual shell wildcards, @samp{\} escapes wildcards,
  5482. and wildcards can match @samp{/}.
  5483. Other than optionally stripping leading @samp{/} from names
  5484. (@pxref{absolute}), patterns and names are used as-is. For
  5485. example, trailing @samp{/} is not trimmed from a user-specified name
  5486. before deciding whether to exclude it.
  5487. However, this matching procedure can be altered by the options listed
  5488. below. These options accumulate. For example:
  5489. @smallexample
  5490. --ignore-case --exclude='makefile' --no-ignore-case ---exclude='readme'
  5491. @end smallexample
  5492. @noindent
  5493. ignores case when excluding @samp{makefile}, but not when excluding
  5494. @samp{readme}.
  5495. @table @option
  5496. @opindex anchored
  5497. @opindex no-anchored
  5498. @item --anchored
  5499. @itemx --no-anchored
  5500. If anchored, a pattern must match an initial subsequence
  5501. of the name's components. Otherwise, the pattern can match any
  5502. subsequence. Default is @option{--no-anchored} for exclusion members
  5503. and @option{--anchored} inclusion members.
  5504. @opindex ignore-case
  5505. @opindex no-ignore-case
  5506. @item --ignore-case
  5507. @itemx --no-ignore-case
  5508. When ignoring case, upper-case patterns match lower-case names and vice versa.
  5509. When not ignoring case (the default), matching is case-sensitive.
  5510. @opindex wildcards-match-slash
  5511. @opindex no-wildcards-match-slash
  5512. @item --wildcards-match-slash
  5513. @itemx --no-wildcards-match-slash
  5514. When wildcards match slash (the default for exclusion members), a
  5515. wildcard like @samp{*} in the pattern can match a @samp{/} in the
  5516. name. Otherwise, @samp{/} is matched only by @samp{/}.
  5517. @end table
  5518. The @option{--recursion} and @option{--no-recursion} options
  5519. (@pxref{recurse}) also affect how member patterns are interpreted. If
  5520. recursion is in effect, a pattern matches a name if it matches any of
  5521. the name's parent directories.
  5522. The following table summarizes pattern-matching default values:
  5523. @multitable @columnfractions .3 .7
  5524. @headitem Members @tab Default settings
  5525. @item Inclusion @tab @option{--no-wildcards --anchored --no-wildcards-match-slash}
  5526. @item Exclusion @tab @option{--wildcards --no-anchored --wildcards-match-slash}
  5527. @end multitable
  5528. @node quoting styles
  5529. @section Quoting Member Names
  5530. When displaying member names, @command{tar} takes care to avoid
  5531. ambiguities caused by certain characters. This is called @dfn{name
  5532. quoting}. The characters in question are:
  5533. @itemize @bullet
  5534. @item Non-printable control characters:
  5535. @multitable @columnfractions 0.20 0.10 0.60
  5536. @headitem Character @tab @acronym{ASCII} @tab Character name
  5537. @item \a @tab 7 @tab Audible bell
  5538. @item \b @tab 8 @tab Backspace
  5539. @item \f @tab 12 @tab Form feed
  5540. @item \n @tab 10 @tab New line
  5541. @item \r @tab 13 @tab Carriage return
  5542. @item \t @tab 9 @tab Horizontal tabulation
  5543. @item \v @tab 11 @tab Vertical tabulation
  5544. @end multitable
  5545. @item Space (@acronym{ASCII} 32)
  5546. @item Single and double quotes (@samp{'} and @samp{"})
  5547. @item Backslash (@samp{\})
  5548. @end itemize
  5549. The exact way @command{tar} uses to quote these characters depends on
  5550. the @dfn{quoting style}. The default quoting style, called
  5551. @dfn{escape} (see below), uses backslash notation to represent control
  5552. characters, space and backslash. Using this quoting style, control
  5553. characters are represented as listed in column @samp{Character} in the
  5554. above table, a space is printed as @samp{\ } and a backslash as @samp{\\}.
  5555. @GNUTAR{} offers seven distinct quoting styles, which can be selected
  5556. using @option{--quoting-style} option:
  5557. @table @option
  5558. @item --quoting-style=@var{style}
  5559. @opindex quoting-style
  5560. Sets quoting style. Valid values for @var{style} argument are:
  5561. literal, shell, shell-always, c, escape, locale, clocale.
  5562. @end table
  5563. These styles are described in detail below. To illustrate their
  5564. effect, we will use an imaginary tar archive @file{arch.tar}
  5565. containing the following members:
  5566. @smallexample
  5567. @group
  5568. # 1. Contains horizontal tabulation character.
  5569. a tab
  5570. # 2. Contains newline character
  5571. a
  5572. newline
  5573. # 3. Contains a space
  5574. a space
  5575. # 4. Contains double quotes
  5576. a"double"quote
  5577. # 5. Contains single quotes
  5578. a'single'quote
  5579. # 6. Contains a backslash character:
  5580. a\backslash
  5581. @end group
  5582. @end smallexample
  5583. Here is how usual @command{ls} command would have listed them, if they
  5584. had existed in the current working directory:
  5585. @smallexample
  5586. @group
  5587. $ @kbd{ls}
  5588. a\ttab
  5589. a\nnewline
  5590. a\ space
  5591. a"double"quote
  5592. a'single'quote
  5593. a\\backslash
  5594. @end group
  5595. @end smallexample
  5596. Quoting styles:
  5597. @table @samp
  5598. @item literal
  5599. No quoting, display each character as is:
  5600. @smallexample
  5601. @group
  5602. $ @kbd{tar tf arch.tar --quoting-style=literal}
  5603. ./
  5604. ./a space
  5605. ./a'single'quote
  5606. ./a"double"quote
  5607. ./a\backslash
  5608. ./a tab
  5609. ./a
  5610. newline
  5611. @end group
  5612. @end smallexample
  5613. @item shell
  5614. Display characters the same way Bourne shell does:
  5615. control characters, except @samp{\t} and @samp{\n}, are printed using
  5616. backslash escapes, @samp{\t} and @samp{\n} are printed as is, and a
  5617. single quote is printed as @samp{\'}. If a name contains any quoted
  5618. characters, it is enclosed in single quotes. In particular, if a name
  5619. contains single quotes, it is printed as several single-quoted strings:
  5620. @smallexample
  5621. @group
  5622. $ @kbd{tar tf arch.tar --quoting-style=shell}
  5623. ./
  5624. './a space'
  5625. './a'\''single'\''quote'
  5626. './a"double"quote'
  5627. './a\backslash'
  5628. './a tab'
  5629. './a
  5630. newline'
  5631. @end group
  5632. @end smallexample
  5633. @item shell-always
  5634. Same as @samp{shell}, but the names are always enclosed in single
  5635. quotes:
  5636. @smallexample
  5637. @group
  5638. $ @kbd{tar tf arch.tar --quoting-style=shell-always}
  5639. './'
  5640. './a space'
  5641. './a'\''single'\''quote'
  5642. './a"double"quote'
  5643. './a\backslash'
  5644. './a tab'
  5645. './a
  5646. newline'
  5647. @end group
  5648. @end smallexample
  5649. @item c
  5650. Use the notation of the C programming language. All names are
  5651. enclosed in double quotes. Control characters are quoted using
  5652. backslash notations, double quotes are represented as @samp{\"},
  5653. backslash characters are represented as @samp{\\}. Single quotes and
  5654. spaces are not quoted:
  5655. @smallexample
  5656. @group
  5657. $ @kbd{tar tf arch.tar --quoting-style=c}
  5658. "./"
  5659. "./a space"
  5660. "./a'single'quote"
  5661. "./a\"double\"quote"
  5662. "./a\\backslash"
  5663. "./a\ttab"
  5664. "./a\nnewline"
  5665. @end group
  5666. @end smallexample
  5667. @item escape
  5668. Control characters are printed using backslash notation, a space is
  5669. printed as @samp{\ } and a backslash as @samp{\\}. This is the
  5670. default quoting style, unless it was changed when configured the
  5671. package.
  5672. @smallexample
  5673. @group
  5674. $ @kbd{tar tf arch.tar --quoting-style=escape}
  5675. ./
  5676. ./a space
  5677. ./a'single'quote
  5678. ./a"double"quote
  5679. ./a\\backslash
  5680. ./a\ttab
  5681. ./a\nnewline
  5682. @end group
  5683. @end smallexample
  5684. @item locale
  5685. Control characters, single quote and backslash are printed using
  5686. backslash notation. All names are quoted using left and right
  5687. quotation marks, appropriate to the current locale. If it does not
  5688. define quotation marks, use @samp{`} as left and @samp{'} as right
  5689. quotation marks. Any occurrences of the right quotation mark in a
  5690. name are escaped with @samp{\}, for example:
  5691. For example:
  5692. @smallexample
  5693. @group
  5694. $ @kbd{tar tf arch.tar --quoting-style=locale}
  5695. `./'
  5696. `./a space'
  5697. `./a\'single\'quote'
  5698. `./a"double"quote'
  5699. `./a\\backslash'
  5700. `./a\ttab'
  5701. `./a\nnewline'
  5702. @end group
  5703. @end smallexample
  5704. @item clocale
  5705. Same as @samp{locale}, but @samp{"} is used for both left and right
  5706. quotation marks, if not provided by the currently selected locale:
  5707. @smallexample
  5708. @group
  5709. $ @kbd{tar tf arch.tar --quoting-style=clocale}
  5710. "./"
  5711. "./a space"
  5712. "./a'single'quote"
  5713. "./a\"double\"quote"
  5714. "./a\\backslash"
  5715. "./a\ttab"
  5716. "./a\nnewline"
  5717. @end group
  5718. @end smallexample
  5719. @end table
  5720. You can specify which characters should be quoted in addition to those
  5721. implied by the current quoting style:
  5722. @table @option
  5723. @item --quote-chars=@var{string}
  5724. Always quote characters from @var{string}, even if the selected
  5725. quoting style would not quote them.
  5726. @end table
  5727. For example, using @samp{escape} quoting (compare with the usual
  5728. escape listing above):
  5729. @smallexample
  5730. @group
  5731. $ @kbd{tar tf arch.tar --quoting-style=escape --quote-chars=' "'}
  5732. ./
  5733. ./a\ space
  5734. ./a'single'quote
  5735. ./a\"double\"quote
  5736. ./a\\backslash
  5737. ./a\ttab
  5738. ./a\nnewline
  5739. @end group
  5740. @end smallexample
  5741. To disable quoting of such additional characters, use the following
  5742. option:
  5743. @table @option
  5744. @item --no-quote-chars=@var{string}
  5745. Remove characters listed in @var{string} from the list of quoted
  5746. characters set by the previous @option{--quote-chars} option.
  5747. @end table
  5748. This option is particularly useful if you have added
  5749. @option{--quote-chars} to your @env{TAR_OPTIONS} (@pxref{TAR_OPTIONS})
  5750. and wish to disable it for the current invocation.
  5751. Note, that @option{--no-quote-chars} does @emph{not} disable those
  5752. characters that are quoted by default in the selected quoting style.
  5753. @node transform
  5754. @section Modifying File and Member Names
  5755. @command{Tar} archives contain detailed information about files stored
  5756. in them and full file names are part of that information. When
  5757. storing file to an archive, its file name is recorded in the archive
  5758. along with the actual file contents. When restoring from an archive,
  5759. a file is created on disk with exactly the same name as that stored
  5760. in the archive. In the majority of cases this is the desired behavior
  5761. of a file archiver. However, there are some cases when it is not.
  5762. First of all, it is often unsafe to extract archive members with
  5763. absolute file names or those that begin with a @file{../}. @GNUTAR{}
  5764. takes special precautions when extracting such names and provides a
  5765. special option for handling them, which is described in
  5766. @ref{absolute}.
  5767. Secondly, you may wish to extract file names without some leading
  5768. directory components, or with otherwise modified names. In other
  5769. cases it is desirable to store files under differing names in the
  5770. archive.
  5771. @GNUTAR{} provides two options for these needs.
  5772. @table @option
  5773. @opindex strip-components
  5774. @item --strip-components=@var{number}
  5775. Strip given @var{number} of leading components from file names before
  5776. extraction.
  5777. @end table
  5778. For example, suppose you have archived whole @file{/usr} hierarchy to
  5779. a tar archive named @file{usr.tar}. Among other files, this archive
  5780. contains @file{usr/include/stdlib.h}, which you wish to extract to
  5781. the current working directory. To do so, you type:
  5782. @smallexample
  5783. $ @kbd{tar -xf usr.tar --strip=2 usr/include/stdlib.h}
  5784. @end smallexample
  5785. The option @option{--strip=2} instructs @command{tar} to strip the
  5786. two leading components (@file{usr/} and @file{include/}) off the file
  5787. name.
  5788. If you add to the above invocation @option{--verbose} (@option{-v})
  5789. option, you will note that the verbose listing still contains the
  5790. full file name, with the two removed components still in place. This
  5791. can be inconvenient, so @command{tar} provides a special option for
  5792. altering this behavior:
  5793. @anchor{show-transformed-names}
  5794. @table @option
  5795. @opindex show-transformed-names
  5796. @item --show-transformed-names
  5797. Display file or member names with all requested transformations
  5798. applied.
  5799. @end table
  5800. @noindent
  5801. For example:
  5802. @smallexample
  5803. @group
  5804. $ @kbd{tar -xf usr.tar -v --strip=2 usr/include/stdlib.h}
  5805. usr/include/stdlib.h
  5806. $ @kbd{tar -xf usr.tar -v --strip=2 --show-transformed usr/include/stdlib.h}
  5807. stdlib.h
  5808. @end group
  5809. @end smallexample
  5810. Notice that in both cases the file is @file{stdlib.h} extracted to the
  5811. current working directory, @option{--show-transformed-names} affects
  5812. only the way its name is displayed.
  5813. This option is especially useful for verifying whether the invocation
  5814. will have the desired effect. Thus, before running
  5815. @smallexample
  5816. $ @kbd{tar -x --strip=@var{n}}
  5817. @end smallexample
  5818. @noindent
  5819. it is often advisable to run
  5820. @smallexample
  5821. $ @kbd{tar -t -v --show-transformed --strip=@var{n}}
  5822. @end smallexample
  5823. @noindent
  5824. to make sure the command will produce the intended results.
  5825. In case you need to apply more complex modifications to the file name,
  5826. @GNUTAR{} provides a general-purpose transformation option:
  5827. @table @option
  5828. @opindex transform
  5829. @item --transform=@var{expression}
  5830. Modify file names using supplied @var{expression}.
  5831. @end table
  5832. @noindent
  5833. The @var{expression} is a @command{sed}-like replace expression of the
  5834. form:
  5835. @smallexample
  5836. s/@var{regexp}/@var{replace}/[@var{flags}]
  5837. @end smallexample
  5838. @noindent
  5839. where @var{regexp} is a @dfn{regular expression}, @var{replace} is a
  5840. replacement for each file name part that matches @var{regexp}. Both
  5841. @var{regexp} and @var{replace} are described in detail in
  5842. @ref{The "s" Command, The "s" Command, The `s' Command, sed, GNU sed}.
  5843. Supported @var{flags} are:
  5844. @table @samp
  5845. @item g
  5846. Apply the replacement to @emph{all} matches to the @var{regexp}, not
  5847. just the first.
  5848. @item i
  5849. Use case-insensitive matching
  5850. @item x
  5851. @var{regexp} is an @dfn{extended regular expression} (@pxref{Extended
  5852. regexps, Extended regular expressions, Extended regular expressions,
  5853. sed, GNU sed}).
  5854. @item @var{number}
  5855. Only replace the @var{number}th match of the @var{regexp}.
  5856. Note: the @var{posix} standard does not specify what should happen
  5857. when you mix the @samp{g} and @var{number} modifiers. @GNUTAR{}
  5858. follows the GNU @command{sed} implementation in this regard, so
  5859. the interaction is defined to be: ignore matches before the
  5860. @var{number}th, and then match and replace all matches from the
  5861. @var{number}th on.
  5862. @end table
  5863. Any delimiter can be used in lieue of @samp{/}, the only requirement being
  5864. that it be used consistently throughout the expression. For example,
  5865. the following two expressions are equivalent:
  5866. @smallexample
  5867. @group
  5868. s/one/two/
  5869. s,one,two,
  5870. @end group
  5871. @end smallexample
  5872. Changing delimiters is often useful when the @var{regex} contains
  5873. slashes. For example, it is more convenient to write @code{s,/,-,} than
  5874. @code{s/\//-/}.
  5875. Here are several examples of @option{--transform} usage:
  5876. @enumerate
  5877. @item Extract @file{usr/} hierarchy into @file{usr/local/}:
  5878. @smallexample
  5879. $ @kbd{tar --transform='s,usr/,usr/local/,' -x -f arch.tar}
  5880. @end smallexample
  5881. @item Strip two leading directory components (equivalent to
  5882. @option{--strip-components=2}):
  5883. @smallexample
  5884. $ @kbd{tar --transform='s,/*[^/]*/[^/]*/,,' -x -f arch.tar}
  5885. @end smallexample
  5886. @item Prepend @file{/prefix/} to each file name:
  5887. @smallexample
  5888. $ @kbd{tar --transform 's,^,/prefix/,' -x -f arch.tar}
  5889. @end smallexample
  5890. @item Convert each file name to lower case:
  5891. @smallexample
  5892. $ @kbd{tar --transform 's/.*/\L&/' -x -f arch.tar}
  5893. @end smallexample
  5894. @end enumerate
  5895. Unlike @option{--strip-components}, @option{--transform} can be used
  5896. in any @GNUTAR{} operation mode. For example, the following command
  5897. adds files to the archive while replacing the leading @file{usr/}
  5898. component with @file{var/}:
  5899. @smallexample
  5900. $ @kbd{tar -cf arch.tar --transform='s,^usr/,var/,' /}
  5901. @end smallexample
  5902. To test @option{--transform} effect we suggest using
  5903. @option{--show-transformed-names} option:
  5904. @smallexample
  5905. $ @kbd{tar -cf arch.tar --transform='s,^usr/,var/,' \
  5906. --verbose --show-transformed-names /}
  5907. @end smallexample
  5908. If both @option{--strip-components} and @option{--transform} are used
  5909. together, then @option{--transform} is applied first, and the required
  5910. number of components is then stripped from its result.
  5911. @node after
  5912. @section Operating Only on New Files
  5913. @UNREVISED
  5914. @cindex Excluding file by age
  5915. @cindex Data Modification time, excluding files by
  5916. @cindex Modification time, excluding files by
  5917. @cindex Age, excluding files by
  5918. The @option{--after-date=@var{date}} (@option{--newer=@var{date}},
  5919. @option{-N @var{date}}) option causes @command{tar} to only work on
  5920. files whose data modification or status change times are newer than
  5921. the @var{date} given. If @var{date} starts with @samp{/} or @samp{.},
  5922. it is taken to be a file name; the data modification time of that file
  5923. is used as the date. If you use this option when creating or appending
  5924. to an archive, the archive will only include new files. If you use
  5925. @option{--after-date} when extracting an archive, @command{tar} will
  5926. only extract files newer than the @var{date} you specify.
  5927. If you only want @command{tar} to make the date comparison based on
  5928. modification of the file's data (rather than status
  5929. changes), then use the @option{--newer-mtime=@var{date}} option.
  5930. You may use these options with any operation. Note that these options
  5931. differ from the @option{--update} (@option{-u}) operation in that they
  5932. allow you to specify a particular date against which @command{tar} can
  5933. compare when deciding whether or not to archive the files.
  5934. @table @option
  5935. @opindex after-date
  5936. @opindex newer
  5937. @item --after-date=@var{date}
  5938. @itemx --newer=@var{date}
  5939. @itemx -N @var{date}
  5940. Only store files newer than @var{date}.
  5941. Acts on files only if their data modification or status change times are
  5942. later than @var{date}. Use in conjunction with any operation.
  5943. If @var{date} starts with @samp{/} or @samp{.}, it is taken to be a file
  5944. name; the data modification time of that file is used as the date.
  5945. @opindex newer-mtime
  5946. @item --newer-mtime=@var{date}
  5947. Acts like @option{--after-date}, but only looks at data modification times.
  5948. @end table
  5949. These options limit @command{tar} to operate only on files which have
  5950. been modified after the date specified. A file's status is considered to have
  5951. changed if its contents have been modified, or if its owner,
  5952. permissions, and so forth, have been changed. (For more information on
  5953. how to specify a date, see @ref{Date input formats}; remember that the
  5954. entire date argument must be quoted if it contains any spaces.)
  5955. Gurus would say that @option{--after-date} tests both the data
  5956. modification time (@code{mtime}, the time the contents of the file
  5957. were last modified) and the status change time (@code{ctime}, the time
  5958. the file's status was last changed: owner, permissions, etc.@:)
  5959. fields, while @option{--newer-mtime} tests only the @code{mtime}
  5960. field.
  5961. To be precise, @option{--after-date} checks @emph{both} @code{mtime} and
  5962. @code{ctime} and processes the file if either one is more recent than
  5963. @var{date}, while @option{--newer-mtime} only checks @code{mtime} and
  5964. disregards @code{ctime}. Neither does it use @code{atime} (the last time the
  5965. contents of the file were looked at).
  5966. Date specifiers can have embedded spaces. Because of this, you may need
  5967. to quote date arguments to keep the shell from parsing them as separate
  5968. arguments. For example, the following command will add to the archive
  5969. all the files modified less than two days ago:
  5970. @smallexample
  5971. $ @kbd{tar -cf foo.tar --newer-mtime '2 days ago'}
  5972. @end smallexample
  5973. When any of these options is used with the option @option{--verbose}
  5974. (@pxref{verbose tutorial}) @GNUTAR{} will try to convert the specified
  5975. date back to its textual representation and compare that with the
  5976. one given with the option. If the two dates differ, @command{tar} will
  5977. print a warning saying what date it will use. This is to help user
  5978. ensure he is using the right date. For example:
  5979. @smallexample
  5980. @group
  5981. $ @kbd{tar -c -f archive.tar --after-date='10 days ago' .}
  5982. tar: Option --after-date: Treating date `10 days ago' as 2006-06-11
  5983. 13:19:37.232434
  5984. @end group
  5985. @end smallexample
  5986. @quotation
  5987. @strong{Please Note:} @option{--after-date} and @option{--newer-mtime}
  5988. should not be used for incremental backups. @xref{Incremental Dumps},
  5989. for proper way of creating incremental backups.
  5990. @end quotation
  5991. @node recurse
  5992. @section Descending into Directories
  5993. @UNREVISED
  5994. @cindex Avoiding recursion in directories
  5995. @cindex Descending directories, avoiding
  5996. @cindex Directories, avoiding recursion
  5997. @cindex Recursion in directories, avoiding
  5998. @FIXME{arrggh! this is still somewhat confusing to me. :-< }
  5999. Usually, @command{tar} will recursively explore all directories (either
  6000. those given on the command line or through the @option{--files-from}
  6001. option) for the various files they contain. However, you may not always
  6002. want @command{tar} to act this way.
  6003. @opindex no-recursion
  6004. The @option{--no-recursion} option inhibits @command{tar}'s recursive descent
  6005. into specified directories. If you specify @option{--no-recursion}, you can
  6006. use the @command{find} utility for hunting through levels of directories to
  6007. construct a list of file names which you could then pass to @command{tar}.
  6008. @command{find} allows you to be more selective when choosing which files to
  6009. archive; see @ref{files}, for more information on using @command{find} with
  6010. @command{tar}, or look.
  6011. @table @option
  6012. @item --no-recursion
  6013. Prevents @command{tar} from recursively descending directories.
  6014. @opindex recursion
  6015. @item --recursion
  6016. Requires @command{tar} to recursively descend directories.
  6017. This is the default.
  6018. @end table
  6019. When you use @option{--no-recursion}, @GNUTAR{} grabs
  6020. directory entries themselves, but does not descend on them
  6021. recursively. Many people use @command{find} for locating files they
  6022. want to back up, and since @command{tar} @emph{usually} recursively
  6023. descends on directories, they have to use the @samp{@w{-not -type d}}
  6024. test in their @command{find} invocation (@pxref{Type, Type, Type test,
  6025. find, Finding Files}), as they usually do not want all the files in a
  6026. directory. They then use the @option{--files-from} option to archive
  6027. the files located via @command{find}.
  6028. The problem when restoring files archived in this manner is that the
  6029. directories themselves are not in the archive; so the
  6030. @option{--same-permissions} (@option{--preserve-permissions},
  6031. @option{-p}) option does not affect them---while users might really
  6032. like it to. Specifying @option{--no-recursion} is a way to tell
  6033. @command{tar} to grab only the directory entries given to it, adding
  6034. no new files on its own. To summarize, if you use @command{find} to
  6035. create a list of files to be stored in an archive, use it as follows:
  6036. @smallexample
  6037. @group
  6038. $ @kbd{find @var{dir} @var{tests} | \
  6039. tar -cf @var{archive} -T - --no-recursion}
  6040. @end group
  6041. @end smallexample
  6042. The @option{--no-recursion} option also applies when extracting: it
  6043. causes @command{tar} to extract only the matched directory entries, not
  6044. the files under those directories.
  6045. The @option{--no-recursion} option also affects how globbing patterns
  6046. are interpreted (@pxref{controlling pattern-matching}).
  6047. The @option{--no-recursion} and @option{--recursion} options apply to
  6048. later options and operands, and can be overridden by later occurrences
  6049. of @option{--no-recursion} and @option{--recursion}. For example:
  6050. @smallexample
  6051. $ @kbd{tar -cf jams.tar --no-recursion grape --recursion grape/concord}
  6052. @end smallexample
  6053. @noindent
  6054. creates an archive with one entry for @file{grape}, and the recursive
  6055. contents of @file{grape/concord}, but no entries under @file{grape}
  6056. other than @file{grape/concord}.
  6057. @node one
  6058. @section Crossing File System Boundaries
  6059. @cindex File system boundaries, not crossing
  6060. @UNREVISED
  6061. @command{tar} will normally automatically cross file system boundaries in
  6062. order to archive files which are part of a directory tree. You can
  6063. change this behavior by running @command{tar} and specifying
  6064. @option{--one-file-system}. This option only affects files that are
  6065. archived because they are in a directory that is being archived;
  6066. @command{tar} will still archive files explicitly named on the command line
  6067. or through @option{--files-from}, regardless of where they reside.
  6068. @table @option
  6069. @opindex one-file-system
  6070. @item --one-file-system
  6071. Prevents @command{tar} from crossing file system boundaries when
  6072. archiving. Use in conjunction with any write operation.
  6073. @end table
  6074. The @option{--one-file-system} option causes @command{tar} to modify its
  6075. normal behavior in archiving the contents of directories. If a file in
  6076. a directory is not on the same file system as the directory itself, then
  6077. @command{tar} will not archive that file. If the file is a directory
  6078. itself, @command{tar} will not archive anything beneath it; in other words,
  6079. @command{tar} will not cross mount points.
  6080. This option is useful for making full or incremental archival backups of
  6081. a file system. If this option is used in conjunction with
  6082. @option{--verbose} (@option{-v}), files that are excluded are
  6083. mentioned by name on the standard error.
  6084. @menu
  6085. * directory:: Changing Directory
  6086. * absolute:: Absolute File Names
  6087. @end menu
  6088. @node directory
  6089. @subsection Changing the Working Directory
  6090. @FIXME{need to read over this node now for continuity; i've switched
  6091. things around some.}
  6092. @cindex Changing directory mid-stream
  6093. @cindex Directory, changing mid-stream
  6094. @cindex Working directory, specifying
  6095. To change the working directory in the middle of a list of file names,
  6096. either on the command line or in a file specified using
  6097. @option{--files-from} (@option{-T}), use @option{--directory} (@option{-C}).
  6098. This will change the working directory to the specified directory
  6099. after that point in the list.
  6100. @table @option
  6101. @opindex directory
  6102. @item --directory=@var{directory}
  6103. @itemx -C @var{directory}
  6104. Changes the working directory in the middle of a command line.
  6105. @end table
  6106. For example,
  6107. @smallexample
  6108. $ @kbd{tar -c -f jams.tar grape prune -C food cherry}
  6109. @end smallexample
  6110. @noindent
  6111. will place the files @file{grape} and @file{prune} from the current
  6112. directory into the archive @file{jams.tar}, followed by the file
  6113. @file{cherry} from the directory @file{food}. This option is especially
  6114. useful when you have several widely separated files that you want to
  6115. store in the same archive.
  6116. Note that the file @file{cherry} is recorded in the archive under the
  6117. precise name @file{cherry}, @emph{not} @file{food/cherry}. Thus, the
  6118. archive will contain three files that all appear to have come from the
  6119. same directory; if the archive is extracted with plain @samp{tar
  6120. --extract}, all three files will be written in the current directory.
  6121. Contrast this with the command,
  6122. @smallexample
  6123. $ @kbd{tar -c -f jams.tar grape prune -C food red/cherry}
  6124. @end smallexample
  6125. @noindent
  6126. which records the third file in the archive under the name
  6127. @file{red/cherry} so that, if the archive is extracted using
  6128. @samp{tar --extract}, the third file will be written in a subdirectory
  6129. named @file{orange-colored}.
  6130. You can use the @option{--directory} option to make the archive
  6131. independent of the original name of the directory holding the files.
  6132. The following command places the files @file{/etc/passwd},
  6133. @file{/etc/hosts}, and @file{/lib/libc.a} into the archive
  6134. @file{foo.tar}:
  6135. @smallexample
  6136. $ @kbd{tar -c -f foo.tar -C /etc passwd hosts -C /lib libc.a}
  6137. @end smallexample
  6138. @noindent
  6139. However, the names of the archive members will be exactly what they were
  6140. on the command line: @file{passwd}, @file{hosts}, and @file{libc.a}.
  6141. They will not appear to be related by file name to the original
  6142. directories where those files were located.
  6143. Note that @option{--directory} options are interpreted consecutively. If
  6144. @option{--directory} specifies a relative file name, it is interpreted
  6145. relative to the then current directory, which might not be the same as
  6146. the original current working directory of @command{tar}, due to a previous
  6147. @option{--directory} option.
  6148. When using @option{--files-from} (@pxref{files}), you can put various
  6149. @command{tar} options (including @option{-C}) in the file list. Notice,
  6150. however, that in this case the option and its argument may not be
  6151. separated by whitespace. If you use short option, its argument must
  6152. either follow the option letter immediately, without any intervening
  6153. whitespace, or occupy the next line. Otherwise, if you use long
  6154. option, separate its argument by an equal sign.
  6155. For instance, the file list for the above example will be:
  6156. @smallexample
  6157. @group
  6158. -C/etc
  6159. passwd
  6160. hosts
  6161. --directory=/lib
  6162. libc.a
  6163. @end group
  6164. @end smallexample
  6165. @noindent
  6166. To use it, you would invoke @command{tar} as follows:
  6167. @smallexample
  6168. $ @kbd{tar -c -f foo.tar --files-from list}
  6169. @end smallexample
  6170. The interpretation of @option{--directory} is disabled by
  6171. @option{--null} option.
  6172. @node absolute
  6173. @subsection Absolute File Names
  6174. @UNREVISED
  6175. @table @option
  6176. @opindex absolute-names
  6177. @item --absolute-names
  6178. @itemx -P
  6179. Do not strip leading slashes from file names, and permit file names
  6180. containing a @file{..} file name component.
  6181. @end table
  6182. By default, @GNUTAR{} drops a leading @samp{/} on
  6183. input or output, and complains about file names containing a @file{..}
  6184. component. This option turns off this behavior.
  6185. When @command{tar} extracts archive members from an archive, it strips any
  6186. leading slashes (@samp{/}) from the member name. This causes absolute
  6187. member names in the archive to be treated as relative file names. This
  6188. allows you to have such members extracted wherever you want, instead of
  6189. being restricted to extracting the member in the exact directory named
  6190. in the archive. For example, if the archive member has the name
  6191. @file{/etc/passwd}, @command{tar} will extract it as if the name were
  6192. really @file{etc/passwd}.
  6193. File names containing @file{..} can cause problems when extracting, so
  6194. @command{tar} normally warns you about such files when creating an
  6195. archive, and rejects attempts to extracts such files.
  6196. Other @command{tar} programs do not do this. As a result, if you
  6197. create an archive whose member names start with a slash, they will be
  6198. difficult for other people with a non-@GNUTAR{}
  6199. program to use. Therefore, @GNUTAR{} also strips
  6200. leading slashes from member names when putting members into the
  6201. archive. For example, if you ask @command{tar} to add the file
  6202. @file{/bin/ls} to an archive, it will do so, but the member name will
  6203. be @file{bin/ls}.@footnote{A side effect of this is that when
  6204. @option{--create} is used with @option{--verbose} the resulting output
  6205. is not, generally speaking, the same as the one you'd get running
  6206. @kbd{tar --list} command. This may be important if you use some
  6207. scripts for comparing both outputs. @xref{listing member and file names},
  6208. for the information on how to handle this case.}
  6209. If you use the @option{--absolute-names} (@option{-P}) option,
  6210. @command{tar} will do none of these transformations.
  6211. To archive or extract files relative to the root directory, specify
  6212. the @option{--absolute-names} (@option{-P}) option.
  6213. Normally, @command{tar} acts on files relative to the working
  6214. directory---ignoring superior directory names when archiving, and
  6215. ignoring leading slashes when extracting.
  6216. When you specify @option{--absolute-names} (@option{-P}),
  6217. @command{tar} stores file names including all superior directory
  6218. names, and preserves leading slashes. If you only invoked
  6219. @command{tar} from the root directory you would never need the
  6220. @option{--absolute-names} option, but using this option
  6221. may be more convenient than switching to root.
  6222. @FIXME{Should be an example in the tutorial/wizardry section using this
  6223. to transfer files between systems.}
  6224. @FIXME{Is write access an issue?}
  6225. @table @option
  6226. @item --absolute-names
  6227. Preserves full file names (including superior directory names) when
  6228. archiving files. Preserves leading slash when extracting files.
  6229. @end table
  6230. @FIXME{this is still horrible; need to talk with dan on monday.}
  6231. @command{tar} prints out a message about removing the @samp{/} from
  6232. file names. This message appears once per @GNUTAR{}
  6233. invocation. It represents something which ought to be told; ignoring
  6234. what it means can cause very serious surprises, later.
  6235. Some people, nevertheless, do not want to see this message. Wanting to
  6236. play really dangerously, one may of course redirect @command{tar} standard
  6237. error to the sink. For example, under @command{sh}:
  6238. @smallexample
  6239. $ @kbd{tar -c -f archive.tar /home 2> /dev/null}
  6240. @end smallexample
  6241. @noindent
  6242. Another solution, both nicer and simpler, would be to change to
  6243. the @file{/} directory first, and then avoid absolute notation.
  6244. For example:
  6245. @smallexample
  6246. $ @kbd{(cd / && tar -c -f archive.tar home)}
  6247. # @i{or}:
  6248. $ @kbd{tar -c -f archive.tar -C / home}
  6249. @end smallexample
  6250. @include getdate.texi
  6251. @node Formats
  6252. @chapter Controlling the Archive Format
  6253. @cindex Tar archive formats
  6254. Due to historical reasons, there are several formats of tar archives.
  6255. All of them are based on the same principles, but have some subtle
  6256. differences that often make them incompatible with each other.
  6257. GNU tar is able to create and handle archives in a variety of formats.
  6258. The most frequently used formats are (in alphabetical order):
  6259. @table @asis
  6260. @item gnu
  6261. Format used by @GNUTAR{} versions up to 1.13.25. This format derived
  6262. from an early @acronym{POSIX} standard, adding some improvements such as
  6263. sparse file handling and incremental archives. Unfortunately these
  6264. features were implemented in a way incompatible with other archive
  6265. formats.
  6266. Archives in @samp{gnu} format are able to hold file names of unlimited
  6267. length.
  6268. @item oldgnu
  6269. Format used by @GNUTAR{} of versions prior to 1.12.
  6270. @item v7
  6271. Archive format, compatible with the V7 implementation of tar. This
  6272. format imposes a number of limitations. The most important of them
  6273. are:
  6274. @enumerate
  6275. @item The maximum length of a file name is limited to 99 characters.
  6276. @item The maximum length of a symbolic link is limited to 99 characters.
  6277. @item It is impossible to store special files (block and character
  6278. devices, fifos etc.)
  6279. @item Maximum value of user or group @acronym{ID} is limited to 2097151 (7777777
  6280. octal)
  6281. @item V7 archives do not contain symbolic ownership information (user
  6282. and group name of the file owner).
  6283. @end enumerate
  6284. This format has traditionally been used by Automake when producing
  6285. Makefiles. This practice will change in the future, in the meantime,
  6286. however this means that projects containing file names more than 99
  6287. characters long will not be able to use @GNUTAR{} @value{VERSION} and
  6288. Automake prior to 1.9.
  6289. @item ustar
  6290. Archive format defined by @acronym{POSIX.1-1988} specification. It stores
  6291. symbolic ownership information. It is also able to store
  6292. special files. However, it imposes several restrictions as well:
  6293. @enumerate
  6294. @item The maximum length of a file name is limited to 256 characters,
  6295. provided that the file name can be split at a directory separator in
  6296. two parts, first of them being at most 155 bytes long. So, in most
  6297. cases the maximum file name length will be shorter than 256
  6298. characters.
  6299. @item The maximum length of a symbolic link name is limited to
  6300. 100 characters.
  6301. @item Maximum size of a file the archive is able to accommodate
  6302. is 8GB
  6303. @item Maximum value of UID/GID is 2097151.
  6304. @item Maximum number of bits in device major and minor numbers is 21.
  6305. @end enumerate
  6306. @item star
  6307. Format used by J@"org Schilling @command{star}
  6308. implementation. @GNUTAR{} is able to read @samp{star} archives but
  6309. currently does not produce them.
  6310. @item posix
  6311. Archive format defined by @acronym{POSIX.1-2001} specification. This is the
  6312. most flexible and feature-rich format. It does not impose any
  6313. restrictions on file sizes or file name lengths. This format is quite
  6314. recent, so not all tar implementations are able to handle it properly.
  6315. However, this format is designed in such a way that any tar
  6316. implementation able to read @samp{ustar} archives will be able to read
  6317. most @samp{posix} archives as well, with the only exception that any
  6318. additional information (such as long file names etc.) will in such
  6319. case be extracted as plain text files along with the files it refers to.
  6320. This archive format will be the default format for future versions
  6321. of @GNUTAR{}.
  6322. @end table
  6323. The following table summarizes the limitations of each of these
  6324. formats:
  6325. @multitable @columnfractions .10 .20 .20 .20 .20
  6326. @headitem Format @tab UID @tab File Size @tab File Name @tab Devn
  6327. @item gnu @tab 1.8e19 @tab Unlimited @tab Unlimited @tab 63
  6328. @item oldgnu @tab 1.8e19 @tab Unlimited @tab Unlimited @tab 63
  6329. @item v7 @tab 2097151 @tab 8GB @tab 99 @tab n/a
  6330. @item ustar @tab 2097151 @tab 8GB @tab 256 @tab 21
  6331. @item posix @tab Unlimited @tab Unlimited @tab Unlimited @tab Unlimited
  6332. @end multitable
  6333. The default format for @GNUTAR{} is defined at compilation
  6334. time. You may check it by running @command{tar --help}, and examining
  6335. the last lines of its output. Usually, @GNUTAR{} is configured
  6336. to create archives in @samp{gnu} format, however, future version will
  6337. switch to @samp{posix}.
  6338. @menu
  6339. * Compression:: Using Less Space through Compression
  6340. * Attributes:: Handling File Attributes
  6341. * Portability:: Making @command{tar} Archives More Portable
  6342. * cpio:: Comparison of @command{tar} and @command{cpio}
  6343. @end menu
  6344. @node Compression
  6345. @section Using Less Space through Compression
  6346. @menu
  6347. * gzip:: Creating and Reading Compressed Archives
  6348. * sparse:: Archiving Sparse Files
  6349. @end menu
  6350. @node gzip
  6351. @subsection Creating and Reading Compressed Archives
  6352. @cindex Compressed archives
  6353. @cindex Storing archives in compressed format
  6354. @GNUTAR{} is able to create and read compressed archives. It supports
  6355. @command{gzip} and @command{bzip2} compression programs. For backward
  6356. compatibility, it also supports @command{compress} command, although
  6357. we strongly recommend against using it, since there is a patent
  6358. covering the algorithm it uses and you could be sued for patent
  6359. infringement merely by running @command{compress}! Besides, it is less
  6360. effective than @command{gzip} and @command{bzip2}.
  6361. Creating a compressed archive is simple: you just specify a
  6362. @dfn{compression option} along with the usual archive creation
  6363. commands. The compression option is @option{-z} (@option{--gzip}) to
  6364. create a @command{gzip} compressed archive, @option{-j}
  6365. (@option{--bzip2}) to create a @command{bzip2} compressed archive, and
  6366. @option{-Z} (@option{--compress}) to use @command{compress} program.
  6367. For example:
  6368. @smallexample
  6369. $ @kbd{tar cfz archive.tar.gz .}
  6370. @end smallexample
  6371. Reading compressed archive is even simpler: you don't need to specify
  6372. any additional options as @GNUTAR{} recognizes its format
  6373. automatically. Thus, the following commands will list and extract the
  6374. archive created in previous example:
  6375. @smallexample
  6376. # List the compressed archive
  6377. $ @kbd{tar tf archive.tar.gz}
  6378. # Extract the compressed archive
  6379. $ @kbd{tar xf archive.tar.gz}
  6380. @end smallexample
  6381. The only case when you have to specify a decompression option while
  6382. reading the archive is when reading from a pipe or from a tape drive
  6383. that does not support random access. However, in this case @GNUTAR{}
  6384. will indicate which option you should use. For example:
  6385. @smallexample
  6386. $ @kbd{cat archive.tar.gz | tar tf -}
  6387. tar: Archive is compressed. Use -z option
  6388. tar: Error is not recoverable: exiting now
  6389. @end smallexample
  6390. If you see such diagnostics, just add the suggested option to the
  6391. invocation of @GNUTAR{}:
  6392. @smallexample
  6393. $ @kbd{cat archive.tar.gz | tar tfz -}
  6394. @end smallexample
  6395. Notice also, that there are several restrictions on operations on
  6396. compressed archives. First of all, compressed archives cannot be
  6397. modified, i.e., you cannot update (@option{--update} (@option{-u})) them or delete
  6398. (@option{--delete}) members from them. Likewise, you cannot append
  6399. another @command{tar} archive to a compressed archive using
  6400. @option{--append} (@option{-r})). Secondly, multi-volume archives cannot be
  6401. compressed.
  6402. The following table summarizes compression options used by @GNUTAR{}.
  6403. @table @option
  6404. @opindex gzip
  6405. @opindex ungzip
  6406. @item -z
  6407. @itemx --gzip
  6408. @itemx --ungzip
  6409. Filter the archive through @command{gzip}.
  6410. You can use @option{--gzip} and @option{--gunzip} on physical devices
  6411. (tape drives, etc.) and remote files as well as on normal files; data
  6412. to or from such devices or remote files is reblocked by another copy
  6413. of the @command{tar} program to enforce the specified (or default) record
  6414. size. The default compression parameters are used; if you need to
  6415. override them, set @env{GZIP} environment variable, e.g.:
  6416. @smallexample
  6417. $ @kbd{GZIP=--best tar cfz archive.tar.gz subdir}
  6418. @end smallexample
  6419. @noindent
  6420. Another way would be to avoid the @option{--gzip} (@option{--gunzip}, @option{--ungzip}, @option{-z}) option and run
  6421. @command{gzip} explicitly:
  6422. @smallexample
  6423. $ @kbd{tar cf - subdir | gzip --best -c - > archive.tar.gz}
  6424. @end smallexample
  6425. @cindex corrupted archives
  6426. About corrupted compressed archives: @command{gzip}'ed files have no
  6427. redundancy, for maximum compression. The adaptive nature of the
  6428. compression scheme means that the compression tables are implicitly
  6429. spread all over the archive. If you lose a few blocks, the dynamic
  6430. construction of the compression tables becomes unsynchronized, and there
  6431. is little chance that you could recover later in the archive.
  6432. There are pending suggestions for having a per-volume or per-file
  6433. compression in @GNUTAR{}. This would allow for viewing the
  6434. contents without decompression, and for resynchronizing decompression at
  6435. every volume or file, in case of corrupted archives. Doing so, we might
  6436. lose some compressibility. But this would have make recovering easier.
  6437. So, there are pros and cons. We'll see!
  6438. @opindex bzip2
  6439. @item -j
  6440. @itemx --bzip2
  6441. Filter the archive through @code{bzip2}. Otherwise like @option{--gzip}.
  6442. @opindex compress
  6443. @opindex uncompress
  6444. @item -Z
  6445. @itemx --compress
  6446. @itemx --uncompress
  6447. Filter the archive through @command{compress}. Otherwise like @option{--gzip}.
  6448. The @acronym{GNU} Project recommends you not use
  6449. @command{compress}, because there is a patent covering the algorithm it
  6450. uses. You could be sued for patent infringement merely by running
  6451. @command{compress}.
  6452. @opindex use-compress-program
  6453. @item --use-compress-program=@var{prog}
  6454. Use external compression program @var{prog}. Use this option if you
  6455. have a compression program that @GNUTAR{} does not support. There
  6456. are two requirements to which @var{prog} should comply:
  6457. First, when called without options, it should read data from standard
  6458. input, compress it and output it on standard output.
  6459. Secondly, if called with @option{-d} argument, it should do exactly
  6460. the opposite, i.e., read the compressed data from the standard input
  6461. and produce uncompressed data on the standard output.
  6462. @end table
  6463. @cindex gpg, using with tar
  6464. @cindex gnupg, using with tar
  6465. @cindex Using encrypted archives
  6466. The @option{--use-compress-program} option, in particular, lets you
  6467. implement your own filters, not necessarily dealing with
  6468. compression/decompression. For example, suppose you wish to implement
  6469. PGP encryption on top of compression, using @command{gpg} (@pxref{Top,
  6470. gpg, gpg ---- encryption and signing tool, gpg, GNU Privacy Guard
  6471. Manual}). The following script does that:
  6472. @smallexample
  6473. @group
  6474. #! /bin/sh
  6475. case $1 in
  6476. -d) gpg --decrypt - | gzip -d -c;;
  6477. '') gzip -c | gpg -s ;;
  6478. *) echo "Unknown option $1">&2; exit 1;;
  6479. esac
  6480. @end group
  6481. @end smallexample
  6482. Suppose you name it @file{gpgz} and save it somewhere in your
  6483. @env{PATH}. Then the following command will create a compressed
  6484. archive signed with your private key:
  6485. @smallexample
  6486. $ @kbd{tar -cf foo.tar.gpgz --use-compress=gpgz .}
  6487. @end smallexample
  6488. @noindent
  6489. Likewise, the following command will list its contents:
  6490. @smallexample
  6491. $ @kbd{tar -tf foo.tar.gpgz --use-compress=gpgz .}
  6492. @end smallexample
  6493. @ignore
  6494. The above is based on the following discussion:
  6495. I have one question, or maybe it's a suggestion if there isn't a way
  6496. to do it now. I would like to use @option{--gzip}, but I'd also like
  6497. the output to be fed through a program like @acronym{GNU}
  6498. @command{ecc} (actually, right now that's @samp{exactly} what I'd like
  6499. to use :-)), basically adding ECC protection on top of compression.
  6500. It seems as if this should be quite easy to do, but I can't work out
  6501. exactly how to go about it. Of course, I can pipe the standard output
  6502. of @command{tar} through @command{ecc}, but then I lose (though I
  6503. haven't started using it yet, I confess) the ability to have
  6504. @command{tar} use @command{rmt} for it's I/O (I think).
  6505. I think the most straightforward thing would be to let me specify a
  6506. general set of filters outboard of compression (preferably ordered,
  6507. so the order can be automatically reversed on input operations, and
  6508. with the options they require specifiable), but beggars shouldn't be
  6509. choosers and anything you decide on would be fine with me.
  6510. By the way, I like @command{ecc} but if (as the comments say) it can't
  6511. deal with loss of block sync, I'm tempted to throw some time at adding
  6512. that capability. Supposing I were to actually do such a thing and
  6513. get it (apparently) working, do you accept contributed changes to
  6514. utilities like that? (Leigh Clayton @file{loc@@soliton.com}, May 1995).
  6515. Isn't that exactly the role of the
  6516. @option{--use-compress-prog=@var{program}} option?
  6517. I never tried it myself, but I suspect you may want to write a
  6518. @var{prog} script or program able to filter stdin to stdout to
  6519. way you want. It should recognize the @option{-d} option, for when
  6520. extraction is needed rather than creation.
  6521. It has been reported that if one writes compressed data (through the
  6522. @option{--gzip} or @option{--compress} options) to a DLT and tries to use
  6523. the DLT compression mode, the data will actually get bigger and one will
  6524. end up with less space on the tape.
  6525. @end ignore
  6526. @node sparse
  6527. @subsection Archiving Sparse Files
  6528. @cindex Sparse Files
  6529. Files in the file system occasionally have @dfn{holes}. A @dfn{hole}
  6530. in a file is a section of the file's contents which was never written.
  6531. The contents of a hole reads as all zeros. On many operating systems,
  6532. actual disk storage is not allocated for holes, but they are counted
  6533. in the length of the file. If you archive such a file, @command{tar}
  6534. could create an archive longer than the original. To have @command{tar}
  6535. attempt to recognize the holes in a file, use @option{--sparse}
  6536. (@option{-S}). When you use this option, then, for any file using
  6537. less disk space than would be expected from its length, @command{tar}
  6538. searches the file for consecutive stretches of zeros. It then records
  6539. in the archive for the file where the consecutive stretches of zeros
  6540. are, and only archives the ``real contents'' of the file. On
  6541. extraction (using @option{--sparse} is not needed on extraction) any
  6542. such files have holes created wherever the continuous stretches of zeros
  6543. were found. Thus, if you use @option{--sparse}, @command{tar} archives
  6544. won't take more space than the original.
  6545. @table @option
  6546. @opindex sparse
  6547. @item -S
  6548. @itemx --sparse
  6549. This option instructs @command{tar} to test each file for sparseness
  6550. before attempting to archive it. If the file is found to be sparse it
  6551. is treated specially, thus allowing to decrease the amount of space
  6552. used by its image in the archive.
  6553. This option is meaningful only when creating or updating archives. It
  6554. has no effect on extraction.
  6555. @end table
  6556. Consider using @option{--sparse} when performing file system backups,
  6557. to avoid archiving the expanded forms of files stored sparsely in the
  6558. system.
  6559. Even if your system has no sparse files currently, some may be
  6560. created in the future. If you use @option{--sparse} while making file
  6561. system backups as a matter of course, you can be assured the archive
  6562. will never take more space on the media than the files take on disk
  6563. (otherwise, archiving a disk filled with sparse files might take
  6564. hundreds of tapes). @xref{Incremental Dumps}.
  6565. However, be aware that @option{--sparse} option presents a serious
  6566. drawback. Namely, in order to determine if the file is sparse
  6567. @command{tar} has to read it before trying to archive it, so in total
  6568. the file is read @strong{twice}. So, always bear in mind that the
  6569. time needed to process all files with this option is roughly twice
  6570. the time needed to archive them without it.
  6571. @FIXME{A technical note:
  6572. Programs like @command{dump} do not have to read the entire file; by
  6573. examining the file system directly, they can determine in advance
  6574. exactly where the holes are and thus avoid reading through them. The
  6575. only data it need read are the actual allocated data blocks.
  6576. @GNUTAR{} uses a more portable and straightforward
  6577. archiving approach, it would be fairly difficult that it does
  6578. otherwise. Elizabeth Zwicky writes to @file{comp.unix.internals}, on
  6579. 1990-12-10:
  6580. @quotation
  6581. What I did say is that you cannot tell the difference between a hole and an
  6582. equivalent number of nulls without reading raw blocks. @code{st_blocks} at
  6583. best tells you how many holes there are; it doesn't tell you @emph{where}.
  6584. Just as programs may, conceivably, care what @code{st_blocks} is (care
  6585. to name one that does?), they may also care where the holes are (I have
  6586. no examples of this one either, but it's equally imaginable).
  6587. I conclude from this that good archivers are not portable. One can
  6588. arguably conclude that if you want a portable program, you can in good
  6589. conscience restore files with as many holes as possible, since you can't
  6590. get it right.
  6591. @end quotation
  6592. }
  6593. @cindex sparse formats, defined
  6594. When using @samp{POSIX} archive format, @GNUTAR{} is able to store
  6595. sparse files using in three distinct ways, called @dfn{sparse
  6596. formats}. A sparse format is identified by its @dfn{number},
  6597. consisting, as usual of two decimal numbers, delimited by a dot. By
  6598. default, format @samp{1.0} is used. If, for some reason, you wish to
  6599. use an earlier format, you can select it using
  6600. @option{--sparse-version} option.
  6601. @table @option
  6602. @opindex sparse-version
  6603. @item --sparse-version=@var{version}
  6604. Select the format to store sparse files in. Valid @var{version} values
  6605. are: @samp{0.0}, @samp{0.1} and @samp{1.0}. @xref{Sparse Formats},
  6606. for a detailed description of each format.
  6607. @end table
  6608. Using @option{--sparse-format} option implies @option{--sparse}.
  6609. @node Attributes
  6610. @section Handling File Attributes
  6611. @UNREVISED
  6612. When @command{tar} reads files, it updates their access times. To
  6613. avoid this, use the @option{--atime-preserve[=METHOD]} option, which can either
  6614. reset the access time retroactively or avoid changing it in the first
  6615. place.
  6616. Handling of file attributes
  6617. @table @option
  6618. @opindex atime-preserve
  6619. @item --atime-preserve
  6620. @itemx --atime-preserve=replace
  6621. @itemx --atime-preserve=system
  6622. Preserve the access times of files that are read. This works only for
  6623. files that you own, unless you have superuser privileges.
  6624. @option{--atime-preserve=replace} works on most systems, but it also
  6625. restores the data modification time and updates the status change
  6626. time. Hence it doesn't interact with incremental dumps nicely
  6627. (@pxref{Incremental Dumps}), and it can set access or data modification times
  6628. incorrectly if other programs access the file while @command{tar} is
  6629. running.
  6630. @option{--atime-preserve=system} avoids changing the access time in
  6631. the first place, if the operating system supports this.
  6632. Unfortunately, this may or may not work on any given operating system
  6633. or file system. If @command{tar} knows for sure it won't work, it
  6634. complains right away.
  6635. Currently @option{--atime-preserve} with no operand defaults to
  6636. @option{--atime-preserve=replace}, but this is intended to change to
  6637. @option{--atime-preserve=system} when the latter is better-supported.
  6638. @opindex touch
  6639. @item -m
  6640. @itemx --touch
  6641. Do not extract data modification time.
  6642. When this option is used, @command{tar} leaves the data modification times
  6643. of the files it extracts as the times when the files were extracted,
  6644. instead of setting it to the times recorded in the archive.
  6645. This option is meaningless with @option{--list} (@option{-t}).
  6646. @opindex same-owner
  6647. @item --same-owner
  6648. Create extracted files with the same ownership they have in the
  6649. archive.
  6650. This is the default behavior for the superuser,
  6651. so this option is meaningful only for non-root users, when @command{tar}
  6652. is executed on those systems able to give files away. This is
  6653. considered as a security flaw by many people, at least because it
  6654. makes quite difficult to correctly account users for the disk space
  6655. they occupy. Also, the @code{suid} or @code{sgid} attributes of
  6656. files are easily and silently lost when files are given away.
  6657. When writing an archive, @command{tar} writes the user @acronym{ID} and user name
  6658. separately. If it can't find a user name (because the user @acronym{ID} is not
  6659. in @file{/etc/passwd}), then it does not write one. When restoring,
  6660. it tries to look the name (if one was written) up in
  6661. @file{/etc/passwd}. If it fails, then it uses the user @acronym{ID} stored in
  6662. the archive instead.
  6663. @opindex no-same-owner
  6664. @item --no-same-owner
  6665. @itemx -o
  6666. Do not attempt to restore ownership when extracting. This is the
  6667. default behavior for ordinary users, so this option has an effect
  6668. only for the superuser.
  6669. @opindex numeric-owner
  6670. @item --numeric-owner
  6671. The @option{--numeric-owner} option allows (ANSI) archives to be written
  6672. without user/group name information or such information to be ignored
  6673. when extracting. It effectively disables the generation and/or use
  6674. of user/group name information. This option forces extraction using
  6675. the numeric ids from the archive, ignoring the names.
  6676. This is useful in certain circumstances, when restoring a backup from
  6677. an emergency floppy with different passwd/group files for example.
  6678. It is otherwise impossible to extract files with the right ownerships
  6679. if the password file in use during the extraction does not match the
  6680. one belonging to the file system(s) being extracted. This occurs,
  6681. for example, if you are restoring your files after a major crash and
  6682. had booted from an emergency floppy with no password file or put your
  6683. disk into another machine to do the restore.
  6684. The numeric ids are @emph{always} saved into @command{tar} archives.
  6685. The identifying names are added at create time when provided by the
  6686. system, unless @option{--old-archive} (@option{-o}) is used. Numeric ids could be
  6687. used when moving archives between a collection of machines using
  6688. a centralized management for attribution of numeric ids to users
  6689. and groups. This is often made through using the NIS capabilities.
  6690. When making a @command{tar} file for distribution to other sites, it
  6691. is sometimes cleaner to use a single owner for all files in the
  6692. distribution, and nicer to specify the write permission bits of the
  6693. files as stored in the archive independently of their actual value on
  6694. the file system. The way to prepare a clean distribution is usually
  6695. to have some Makefile rule creating a directory, copying all needed
  6696. files in that directory, then setting ownership and permissions as
  6697. wanted (there are a lot of possible schemes), and only then making a
  6698. @command{tar} archive out of this directory, before cleaning
  6699. everything out. Of course, we could add a lot of options to
  6700. @GNUTAR{} for fine tuning permissions and ownership.
  6701. This is not the good way, I think. @GNUTAR{} is
  6702. already crowded with options and moreover, the approach just explained
  6703. gives you a great deal of control already.
  6704. @xopindex{same-permissions, short description}
  6705. @xopindex{preserve-permissions, short description}
  6706. @item -p
  6707. @itemx --same-permissions
  6708. @itemx --preserve-permissions
  6709. Extract all protection information.
  6710. This option causes @command{tar} to set the modes (access permissions) of
  6711. extracted files exactly as recorded in the archive. If this option
  6712. is not used, the current @code{umask} setting limits the permissions
  6713. on extracted files. This option is by default enabled when
  6714. @command{tar} is executed by a superuser.
  6715. This option is meaningless with @option{--list} (@option{-t}).
  6716. @opindex preserve
  6717. @item --preserve
  6718. Same as both @option{--same-permissions} and @option{--same-order}.
  6719. The @option{--preserve} option has no equivalent short option name.
  6720. It is equivalent to @option{--same-permissions} plus @option{--same-order}.
  6721. @FIXME{I do not see the purpose of such an option. (Neither I. FP.)
  6722. Neither do I. --Sergey}
  6723. @end table
  6724. @node Portability
  6725. @section Making @command{tar} Archives More Portable
  6726. Creating a @command{tar} archive on a particular system that is meant to be
  6727. useful later on many other machines and with other versions of @command{tar}
  6728. is more challenging than you might think. @command{tar} archive formats
  6729. have been evolving since the first versions of Unix. Many such formats
  6730. are around, and are not always compatible with each other. This section
  6731. discusses a few problems, and gives some advice about making @command{tar}
  6732. archives more portable.
  6733. One golden rule is simplicity. For example, limit your @command{tar}
  6734. archives to contain only regular files and directories, avoiding
  6735. other kind of special files. Do not attempt to save sparse files or
  6736. contiguous files as such. Let's discuss a few more problems, in turn.
  6737. @FIXME{Discuss GNU extensions (incremental backups, multi-volume
  6738. archives and archive labels) in GNU and PAX formats.}
  6739. @menu
  6740. * Portable Names:: Portable Names
  6741. * dereference:: Symbolic Links
  6742. * old:: Old V7 Archives
  6743. * ustar:: Ustar Archives
  6744. * gnu:: GNU and old GNU format archives.
  6745. * posix:: @acronym{POSIX} archives
  6746. * Checksumming:: Checksumming Problems
  6747. * Large or Negative Values:: Large files, negative time stamps, etc.
  6748. * Other Tars:: How to Extract GNU-Specific Data Using
  6749. Other @command{tar} Implementations
  6750. @end menu
  6751. @node Portable Names
  6752. @subsection Portable Names
  6753. Use portable file and member names. A name is portable if it contains
  6754. only @acronym{ASCII} letters and digits, @samp{/}, @samp{.}, @samp{_}, and
  6755. @samp{-}; it cannot be empty, start with @samp{-} or @samp{//}, or
  6756. contain @samp{/-}. Avoid deep directory nesting. For portability to
  6757. old Unix hosts, limit your file name components to 14 characters or
  6758. less.
  6759. If you intend to have your @command{tar} archives to be read under
  6760. MSDOS, you should not rely on case distinction for file names, and you
  6761. might use the @acronym{GNU} @command{doschk} program for helping you
  6762. further diagnosing illegal MSDOS names, which are even more limited
  6763. than System V's.
  6764. @node dereference
  6765. @subsection Symbolic Links
  6766. @cindex File names, using symbolic links
  6767. @cindex Symbolic link as file name
  6768. @opindex dereference
  6769. Normally, when @command{tar} archives a symbolic link, it writes a
  6770. block to the archive naming the target of the link. In that way, the
  6771. @command{tar} archive is a faithful record of the file system contents.
  6772. @option{--dereference} (@option{-h}) is used with @option{--create} (@option{-c}), and causes
  6773. @command{tar} to archive the files symbolic links point to, instead of
  6774. the links themselves. When this option is used, when @command{tar}
  6775. encounters a symbolic link, it will archive the linked-to file,
  6776. instead of simply recording the presence of a symbolic link.
  6777. The name under which the file is stored in the file system is not
  6778. recorded in the archive. To record both the symbolic link name and
  6779. the file name in the system, archive the file under both names. If
  6780. all links were recorded automatically by @command{tar}, an extracted file
  6781. might be linked to a file name that no longer exists in the file
  6782. system.
  6783. If a linked-to file is encountered again by @command{tar} while creating
  6784. the same archive, an entire second copy of it will be stored. (This
  6785. @emph{might} be considered a bug.)
  6786. So, for portable archives, do not archive symbolic links as such,
  6787. and use @option{--dereference} (@option{-h}): many systems do not support
  6788. symbolic links, and moreover, your distribution might be unusable if
  6789. it contains unresolved symbolic links.
  6790. @node old
  6791. @subsection Old V7 Archives
  6792. @cindex Format, old style
  6793. @cindex Old style format
  6794. @cindex Old style archives
  6795. @cindex v7 archive format
  6796. Certain old versions of @command{tar} cannot handle additional
  6797. information recorded by newer @command{tar} programs. To create an
  6798. archive in V7 format (not ANSI), which can be read by these old
  6799. versions, specify the @option{--format=v7} option in
  6800. conjunction with the @option{--create} (@option{-c}) (@command{tar} also
  6801. accepts @option{--portability} or @option{--old-archive} for this
  6802. option). When you specify it,
  6803. @command{tar} leaves out information about directories, pipes, fifos,
  6804. contiguous files, and device files, and specifies file ownership by
  6805. group and user IDs instead of group and user names.
  6806. When updating an archive, do not use @option{--format=v7}
  6807. unless the archive was created using this option.
  6808. In most cases, a @emph{new} format archive can be read by an @emph{old}
  6809. @command{tar} program without serious trouble, so this option should
  6810. seldom be needed. On the other hand, most modern @command{tar}s are
  6811. able to read old format archives, so it might be safer for you to
  6812. always use @option{--format=v7} for your distributions. Notice,
  6813. however, that @samp{ustar} format is a better alternative, as it is
  6814. free from many of @samp{v7}'s drawbacks.
  6815. @node ustar
  6816. @subsection Ustar Archive Format
  6817. @cindex ustar archive format
  6818. Archive format defined by @acronym{POSIX}.1-1988 specification is called
  6819. @code{ustar}. Although it is more flexible than the V7 format, it
  6820. still has many restrictions (@xref{Formats,ustar}, for the detailed
  6821. description of @code{ustar} format). Along with V7 format,
  6822. @code{ustar} format is a good choice for archives intended to be read
  6823. with other implementations of @command{tar}.
  6824. To create archive in @code{ustar} format, use @option{--format=ustar}
  6825. option in conjunction with the @option{--create} (@option{-c}).
  6826. @node gnu
  6827. @subsection @acronym{GNU} and old @GNUTAR{} format
  6828. @cindex GNU archive format
  6829. @cindex Old GNU archive format
  6830. @GNUTAR{} was based on an early draft of the
  6831. @acronym{POSIX} 1003.1 @code{ustar} standard. @acronym{GNU} extensions to
  6832. @command{tar}, such as the support for file names longer than 100
  6833. characters, use portions of the @command{tar} header record which were
  6834. specified in that @acronym{POSIX} draft as unused. Subsequent changes in
  6835. @acronym{POSIX} have allocated the same parts of the header record for
  6836. other purposes. As a result, @GNUTAR{} format is
  6837. incompatible with the current @acronym{POSIX} specification, and with
  6838. @command{tar} programs that follow it.
  6839. In the majority of cases, @command{tar} will be configured to create
  6840. this format by default. This will change in future releases, since
  6841. we plan to make @samp{POSIX} format the default.
  6842. To force creation a @GNUTAR{} archive, use option
  6843. @option{--format=gnu}.
  6844. @node posix
  6845. @subsection @GNUTAR{} and @acronym{POSIX} @command{tar}
  6846. @cindex POSIX archive format
  6847. @cindex PAX archive format
  6848. Starting from version 1.14 @GNUTAR{} features full support for
  6849. @acronym{POSIX.1-2001} archives.
  6850. A @acronym{POSIX} conformant archive will be created if @command{tar}
  6851. was given @option{--format=posix} (@option{--format=pax}) option. No
  6852. special option is required to read and extract from a @acronym{POSIX}
  6853. archive.
  6854. @menu
  6855. * PAX keywords:: Controlling Extended Header Keywords.
  6856. @end menu
  6857. @node PAX keywords
  6858. @subsubsection Controlling Extended Header Keywords
  6859. @table @option
  6860. @opindex pax-option
  6861. @item --pax-option=@var{keyword-list}
  6862. Handle keywords in @acronym{PAX} extended headers. This option is
  6863. equivalent to @option{-o} option of the @command{pax} utility.
  6864. @end table
  6865. @var{Keyword-list} is a comma-separated
  6866. list of keyword options, each keyword option taking one of
  6867. the following forms:
  6868. @table @code
  6869. @item delete=@var{pattern}
  6870. When used with one of archive-creation commands,
  6871. this option instructs @command{tar} to omit from extended header records
  6872. that it produces any keywords matching the string @var{pattern}.
  6873. When used in extract or list mode, this option instructs tar
  6874. to ignore any keywords matching the given @var{pattern} in the extended
  6875. header records. In both cases, matching is performed using the pattern
  6876. matching notation described in @acronym{POSIX 1003.2}, 3.13
  6877. (@pxref{wildcards}). For example:
  6878. @smallexample
  6879. --pax-option delete=security.*
  6880. @end smallexample
  6881. would suppress security-related information.
  6882. @item exthdr.name=@var{string}
  6883. This keyword allows user control over the name that is written into the
  6884. ustar header blocks for the extended headers. The name is obtained
  6885. from @var{string} after making the following substitutions:
  6886. @multitable @columnfractions .25 .55
  6887. @headitem Meta-character @tab Replaced By
  6888. @item %d @tab The directory name of the file, equivalent to the
  6889. result of the @command{dirname} utility on the translated file name.
  6890. @item %f @tab The name of the file with the directory information
  6891. stripped, equivalent to the result of the @command{basename} utility
  6892. on the translated file name.
  6893. @item %p @tab The process @acronym{ID} of the @command{tar} process.
  6894. @item %% @tab A @samp{%} character.
  6895. @end multitable
  6896. Any other @samp{%} characters in @var{string} produce undefined
  6897. results.
  6898. If no option @samp{exthdr.name=string} is specified, @command{tar}
  6899. will use the following default value:
  6900. @smallexample
  6901. %d/PaxHeaders.%p/%f
  6902. @end smallexample
  6903. @item globexthdr.name=@var{string}
  6904. This keyword allows user control over the name that is written into
  6905. the ustar header blocks for global extended header records. The name
  6906. is obtained from the contents of @var{string}, after making
  6907. the following substitutions:
  6908. @multitable @columnfractions .25 .55
  6909. @headitem Meta-character @tab Replaced By
  6910. @item %n @tab An integer that represents the
  6911. sequence number of the global extended header record in the archive,
  6912. starting at 1.
  6913. @item %p @tab The process @acronym{ID} of the @command{tar} process.
  6914. @item %% @tab A @samp{%} character.
  6915. @end multitable
  6916. Any other @samp{%} characters in @var{string} produce undefined results.
  6917. If no option @samp{globexthdr.name=string} is specified, @command{tar}
  6918. will use the following default value:
  6919. @smallexample
  6920. $TMPDIR/GlobalHead.%p.%n
  6921. @end smallexample
  6922. @noindent
  6923. where @samp{$TMPDIR} represents the value of the @var{TMPDIR}
  6924. environment variable. If @var{TMPDIR} is not set, @command{tar}
  6925. uses @samp{/tmp}.
  6926. @item @var{keyword}=@var{value}
  6927. When used with one of archive-creation commands, these keyword/value pairs
  6928. will be included at the beginning of the archive in a global extended
  6929. header record. When used with one of archive-reading commands,
  6930. @command{tar} will behave as if it has encountered these keyword/value
  6931. pairs at the beginning of the archive in a global extended header
  6932. record.
  6933. @item @var{keyword}:=@var{value}
  6934. When used with one of archive-creation commands, these keyword/value pairs
  6935. will be included as records at the beginning of an extended header for
  6936. each file. This is effectively equivalent to @var{keyword}=@var{value}
  6937. form except that it creates no global extended header records.
  6938. When used with one of archive-reading commands, @command{tar} will
  6939. behave as if these keyword/value pairs were included as records at the
  6940. end of each extended header; thus, they will override any global or
  6941. file-specific extended header record keywords of the same names.
  6942. For example, in the command:
  6943. @smallexample
  6944. tar --format=posix --create \
  6945. --file archive --pax-option gname:=user .
  6946. @end smallexample
  6947. the group name will be forced to a new value for all files
  6948. stored in the archive.
  6949. @end table
  6950. @node Checksumming
  6951. @subsection Checksumming Problems
  6952. SunOS and HP-UX @command{tar} fail to accept archives created using
  6953. @GNUTAR{} and containing non-@acronym{ASCII} file names, that
  6954. is, file names having characters with the eight bit set, because they
  6955. use signed checksums, while @GNUTAR{} uses unsigned
  6956. checksums while creating archives, as per @acronym{POSIX} standards. On
  6957. reading, @GNUTAR{} computes both checksums and
  6958. accept any. It is somewhat worrying that a lot of people may go
  6959. around doing backup of their files using faulty (or at least
  6960. non-standard) software, not learning about it until it's time to
  6961. restore their missing files with an incompatible file extractor, or
  6962. vice versa.
  6963. @GNUTAR{} compute checksums both ways, and accept
  6964. any on read, so @acronym{GNU} tar can read Sun tapes even with their
  6965. wrong checksums. @GNUTAR{} produces the standard
  6966. checksum, however, raising incompatibilities with Sun. That is to
  6967. say, @GNUTAR{} has not been modified to
  6968. @emph{produce} incorrect archives to be read by buggy @command{tar}'s.
  6969. I've been told that more recent Sun @command{tar} now read standard
  6970. archives, so maybe Sun did a similar patch, after all?
  6971. The story seems to be that when Sun first imported @command{tar}
  6972. sources on their system, they recompiled it without realizing that
  6973. the checksums were computed differently, because of a change in
  6974. the default signing of @code{char}'s in their compiler. So they
  6975. started computing checksums wrongly. When they later realized their
  6976. mistake, they merely decided to stay compatible with it, and with
  6977. themselves afterwards. Presumably, but I do not really know, HP-UX
  6978. has chosen that their @command{tar} archives to be compatible with Sun's.
  6979. The current standards do not favor Sun @command{tar} format. In any
  6980. case, it now falls on the shoulders of SunOS and HP-UX users to get
  6981. a @command{tar} able to read the good archives they receive.
  6982. @node Large or Negative Values
  6983. @subsection Large or Negative Values
  6984. @cindex large values
  6985. @cindex future time stamps
  6986. @cindex negative time stamps
  6987. @UNREVISED{}
  6988. The above sections suggest to use @samp{oldest possible} archive
  6989. format if in doubt. However, sometimes it is not possible. If you
  6990. attempt to archive a file whose metadata cannot be represented using
  6991. required format, @GNUTAR{} will print error message and ignore such a
  6992. file. You will than have to switch to a format that is able to
  6993. handle such values. The format summary table (@pxref{Formats}) will
  6994. help you to do so.
  6995. In particular, when trying to archive files larger than 8GB or with
  6996. timestamps not in the range 1970-01-01 00:00:00 through 2242-03-16
  6997. 12:56:31 @sc{utc}, you will have to chose between @acronym{GNU} and
  6998. @acronym{POSIX} archive formats. When considering which format to
  6999. choose, bear in mind that the @acronym{GNU} format uses
  7000. two's-complement base-256 notation to store values that do not fit
  7001. into standard @acronym{ustar} range. Such archives can generally be
  7002. read only by a @GNUTAR{} implementation. Moreover, they sometimes
  7003. cannot be correctly restored on another hosts even by @GNUTAR{}. For
  7004. example, using two's complement representation for negative time
  7005. stamps that assumes a signed 32-bit @code{time_t} generates archives
  7006. that are not portable to hosts with differing @code{time_t}
  7007. representations.
  7008. On the other hand, @acronym{POSIX} archives, generally speaking, can
  7009. be extracted by any tar implementation that understands older
  7010. @acronym{ustar} format. The only exception are files larger than 8GB.
  7011. @FIXME{Describe how @acronym{POSIX} archives are extracted by non
  7012. POSIX-aware tars.}
  7013. @node Other Tars
  7014. @subsection How to Extract GNU-Specific Data Using Other @command{tar} Implementations
  7015. In previous sections you became acquainted with various quirks
  7016. necessary to make your archives portable. Sometimes you may need to
  7017. extract archives containing GNU-specific members using some
  7018. third-party @command{tar} implementation or an older version of
  7019. @GNUTAR{}. Of course your best bet is to have @GNUTAR{} installed,
  7020. but if it is for some reason impossible, this section will explain
  7021. how to cope without it.
  7022. When we speak about @dfn{GNU-specific} members we mean two classes of
  7023. them: members split between the volumes of a multi-volume archive and
  7024. sparse members. You will be able to always recover such members if
  7025. the archive is in PAX format. In addition split members can be
  7026. recovered from archives in old GNU format. The following subsections
  7027. describe the required procedures in detail.
  7028. @menu
  7029. * Split Recovery:: Members Split Between Volumes
  7030. * Sparse Recovery:: Sparse Members
  7031. @end menu
  7032. @node Split Recovery
  7033. @subsubsection Extracting Members Split Between Volumes
  7034. @cindex Mutli-volume archives, extracting using non-GNU tars
  7035. If a member is split between several volumes of an old GNU format archive
  7036. most third party @command{tar} implementation will fail to extract
  7037. it. To extract it, use @command{tarcat} program (@pxref{Tarcat}).
  7038. This program is available from
  7039. @uref{http://www.gnu.org/@/software/@/tar/@/utils/@/tarcat.html, @GNUTAR{}
  7040. home page}. It concatenates several archive volumes into a single
  7041. valid archive. For example, if you have three volumes named from
  7042. @file{vol-1.tar} to @file{vol-3.tar}, you can do the following to
  7043. extract them using a third-party @command{tar}:
  7044. @smallexample
  7045. $ @kbd{tarcat vol-1.tar vol-2.tar vol-3.tar | tar xf -}
  7046. @end smallexample
  7047. @cindex Mutli-volume archives in PAX format, extracting using non-GNU tars
  7048. You could use this approach for most (although not all) PAX
  7049. format archives as well. However, extracting split members from a PAX
  7050. archive is a much easier task, because PAX volumes are constructed in
  7051. such a way that each part of a split member is extracted to a
  7052. different file by @command{tar} implementations that are not aware of
  7053. GNU extensions. More specifically, the very first part retains its
  7054. original name, and all subsequent parts are named using the pattern:
  7055. @smallexample
  7056. %d/GNUFileParts.%p/%f.%n
  7057. @end smallexample
  7058. @noindent
  7059. where symbols preceeded by @samp{%} are @dfn{macro characters} that
  7060. have the following meaning:
  7061. @multitable @columnfractions .25 .55
  7062. @headitem Meta-character @tab Replaced By
  7063. @item %d @tab The directory name of the file, equivalent to the
  7064. result of the @command{dirname} utility on its full name.
  7065. @item %f @tab The file name of the file, equivalent to the result
  7066. of the @command{basename} utility on its full name.
  7067. @item %p @tab The process @acronym{ID} of the @command{tar} process that
  7068. created the archive.
  7069. @item %n @tab Ordinal number of this particular part.
  7070. @end multitable
  7071. For example, if the file @file{var/longfile} was split during archive
  7072. creation between three volumes, and the creator @command{tar} process
  7073. had process @acronym{ID} @samp{27962}, then the member names will be:
  7074. @smallexample
  7075. var/longfile
  7076. var/GNUFileParts.27962/longfile.1
  7077. var/GNUFileParts.27962/longfile.2
  7078. @end smallexample
  7079. When you extract your archive using a third-party @command{tar}, these
  7080. files will be created on your disk, and the only thing you will need
  7081. to do to restore your file in its original form is concatenate them in
  7082. the proper order, for example:
  7083. @smallexample
  7084. @group
  7085. $ @kbd{cd var}
  7086. $ @kbd{cat GNUFileParts.27962/longfile.1 \
  7087. GNUFileParts.27962/longfile.2 >> longfile}
  7088. $ rm -f GNUFileParts.27962
  7089. @end group
  7090. @end smallexample
  7091. Notice, that if the @command{tar} implementation you use supports PAX
  7092. format archives, it will probably emit warnings about unknown keywords
  7093. during extraction. They will look like this:
  7094. @smallexample
  7095. @group
  7096. Tar file too small
  7097. Unknown extended header keyword 'GNU.volume.filename' ignored.
  7098. Unknown extended header keyword 'GNU.volume.size' ignored.
  7099. Unknown extended header keyword 'GNU.volume.offset' ignored.
  7100. @end group
  7101. @end smallexample
  7102. @noindent
  7103. You can safely ignore these warnings.
  7104. If your @command{tar} implementation is not PAX-aware, you will get
  7105. more warnings and more files generated on your disk, e.g.:
  7106. @smallexample
  7107. @group
  7108. $ @kbd{tar xf vol-1.tar}
  7109. var/PaxHeaders.27962/longfile: Unknown file type 'x', extracted as
  7110. normal file
  7111. Unexpected EOF in archive
  7112. $ @kbd{tar xf vol-2.tar}
  7113. tmp/GlobalHead.27962.1: Unknown file type 'g', extracted as normal file
  7114. GNUFileParts.27962/PaxHeaders.27962/sparsefile.1: Unknown file type
  7115. 'x', extracted as normal file
  7116. @end group
  7117. @end smallexample
  7118. Ignore these warnings. The @file{PaxHeaders.*} directories created
  7119. will contain files with @dfn{extended header keywords} describing the
  7120. extracted files. You can delete them, unless they describe sparse
  7121. members. Read further to learn more about them.
  7122. @node Sparse Recovery
  7123. @subsubsection Extracting Sparse Members
  7124. @cindex sparse files, extracting with non-GNU tars
  7125. Any @command{tar} implementation will be able to extract sparse members from a
  7126. PAX archive. However, the extracted files will be @dfn{condensed},
  7127. i.e., any zero blocks will be removed from them. When we restore such
  7128. a condensed file to its original form, by adding zero blocks (or
  7129. @dfn{holes}) back to their original locations, we call this process
  7130. @dfn{expanding} a compressed sparse file.
  7131. @pindex xsparse
  7132. To expand a file, you will need a simple auxiliary program called
  7133. @command{xsparse}. It is available in source form from
  7134. @uref{http://www.gnu.org/@/software/@/tar/@/utils/@/xsparse.html, @GNUTAR{}
  7135. home page}.
  7136. @cindex sparse files v.1.0, extracting with non-GNU tars
  7137. Let's begin with archive members in @dfn{sparse format
  7138. version 1.0}@footnote{@xref{PAX 1}.}, which are the easiest to expand.
  7139. The condensed file will contain both file map and file data, so no
  7140. additional data will be needed to restore it. If the original file
  7141. name was @file{@var{dir}/@var{name}}, then the condensed file will be
  7142. named @file{@var{dir}/@/GNUSparseFile.@var{n}/@/@var{name}}, where
  7143. @var{n} is a decimal number@footnote{technically speaking, @var{n} is a
  7144. @dfn{process @acronym{ID}} of the @command{tar} process which created the
  7145. archive (@pxref{PAX keywords}).}.
  7146. To expand a version 1.0 file, run @command{xsparse} as follows:
  7147. @smallexample
  7148. $ @kbd{xsparse @file{cond-file}}
  7149. @end smallexample
  7150. @noindent
  7151. where @file{cond-file} is the name of the condensed file. The utility
  7152. will deduce the name for the resulting expanded file using the
  7153. following algorithm:
  7154. @enumerate 1
  7155. @item If @file{cond-file} does not contain any directories,
  7156. @file{../cond-file} will be used;
  7157. @item If @file{cond-file} has the form
  7158. @file{@var{dir}/@var{t}/@var{name}}, where both @var{t} and @var{name}
  7159. are simple names, with no @samp{/} characters in them, the output file
  7160. name will be @file{@var{dir}/@var{name}}.
  7161. @item Otherwise, if @file{cond-file} has the form
  7162. @file{@var{dir}/@var{name}}, the output file name will be
  7163. @file{@var{name}}.
  7164. @end enumerate
  7165. In the unlikely case when this algorithm does not suit your needs,
  7166. you can explicitly specify output file name as a second argument to
  7167. the command:
  7168. @smallexample
  7169. $ @kbd{xsparse @file{cond-file} @file{out-file}}
  7170. @end smallexample
  7171. It is often a good idea to run @command{xsparse} in @dfn{dry run} mode
  7172. first. In this mode, the command does not actually expand the file,
  7173. but verbosely lists all actions it would be taking to do so. The dry
  7174. run mode is enabled by @option{-n} command line argument:
  7175. @smallexample
  7176. @group
  7177. $ @kbd{xsparse -n /home/gray/GNUSparseFile.6058/sparsefile}
  7178. Reading v.1.0 sparse map
  7179. Expanding file `/home/gray/GNUSparseFile.6058/sparsefile' to
  7180. `/home/gray/sparsefile'
  7181. Finished dry run
  7182. @end group
  7183. @end smallexample
  7184. To actually expand the file, you would run:
  7185. @smallexample
  7186. $ @kbd{xsparse /home/gray/GNUSparseFile.6058/sparsefile}
  7187. @end smallexample
  7188. @noindent
  7189. The program behaves the same way all UNIX utilities do: it will keep
  7190. quiet unless it has simething important to tell you (e.g. an error
  7191. condition or something). If you wish it to produce verbose output,
  7192. similar to that from the dry run mode, use @option{-v} option:
  7193. @smallexample
  7194. @group
  7195. $ @kbd{xsparse -v /home/gray/GNUSparseFile.6058/sparsefile}
  7196. Reading v.1.0 sparse map
  7197. Expanding file `/home/gray/GNUSparseFile.6058/sparsefile' to
  7198. `/home/gray/sparsefile'
  7199. Done
  7200. @end group
  7201. @end smallexample
  7202. Additionally, if your @command{tar} implementation has extracted the
  7203. @dfn{extended headers} for this file, you can instruct @command{xstar}
  7204. to use them in order to verify the integrity of the expanded file.
  7205. The option @option{-x} sets the name of the extended header file to
  7206. use. Continuing our example:
  7207. @smallexample
  7208. @group
  7209. $ @kbd{xsparse -v -x /home/gray/PaxHeaders.6058/sparsefile \
  7210. /home/gray/GNUSparseFile.6058/sparsefile}
  7211. Reading extended header file
  7212. Found variable GNU.sparse.major = 1
  7213. Found variable GNU.sparse.minor = 0
  7214. Found variable GNU.sparse.name = sparsefile
  7215. Found variable GNU.sparse.realsize = 217481216
  7216. Reading v.1.0 sparse map
  7217. Expanding file `/home/gray/GNUSparseFile.6058/sparsefile' to
  7218. `/home/gray/sparsefile'
  7219. Done
  7220. @end group
  7221. @end smallexample
  7222. @anchor{extracting sparse v.0.x}
  7223. @cindex sparse files v.0.1, extracting with non-GNU tars
  7224. @cindex sparse files v.0.0, extracting with non-GNU tars
  7225. An @dfn{extended header} is a special @command{tar} archive header
  7226. that precedes an archive member and contains a set of
  7227. @dfn{variables}, describing the member properties that cannot be
  7228. stored in the standard @code{ustar} header. While optional for
  7229. expanding sparse version 1.0 members, the use of extended headers is
  7230. mandatory when expanding sparse members in older sparse formats: v.0.0
  7231. and v.0.1 (The sparse formats are described in detail in @ref{Sparse
  7232. Formats}.) So, for these formats, the question is: how to obtain
  7233. extended headers from the archive?
  7234. If you use a @command{tar} implementation that does not support PAX
  7235. format, extended headers for each member will be extracted as a
  7236. separate file. If we represent the member name as
  7237. @file{@var{dir}/@var{name}}, then the extended header file will be
  7238. named @file{@var{dir}/@/PaxHeaders.@var{n}/@/@var{name}}, where
  7239. @var{n} is an integer number.
  7240. Things become more difficult if your @command{tar} implementation
  7241. does support PAX headers, because in this case you will have to
  7242. manually extract the headers. We recommend the following algorithm:
  7243. @enumerate 1
  7244. @item
  7245. Consult the documentation of your @command{tar} implementation for an
  7246. option that prints @dfn{block numbers} along with the archive
  7247. listing (analogous to @GNUTAR{}'s @option{-R} option). For example,
  7248. @command{star} has @option{-block-number}.
  7249. @item
  7250. Obtain verbose listing using the @samp{block number} option, and
  7251. find block numbers of the sparse member in question and the member
  7252. immediately following it. For example, running @command{star} on our
  7253. archive we obtain:
  7254. @smallexample
  7255. @group
  7256. $ @kbd{star -t -v -block-number -f arc.tar}
  7257. @dots{}
  7258. star: Unknown extended header keyword 'GNU.sparse.size' ignored.
  7259. star: Unknown extended header keyword 'GNU.sparse.numblocks' ignored.
  7260. star: Unknown extended header keyword 'GNU.sparse.name' ignored.
  7261. star: Unknown extended header keyword 'GNU.sparse.map' ignored.
  7262. block 56: 425984 -rw-r--r-- gray/users Jun 25 14:46 2006 GNUSparseFile.28124/sparsefile
  7263. block 897: 65391 -rw-r--r-- gray/users Jun 24 20:06 2006 README
  7264. @dots{}
  7265. @end group
  7266. @end smallexample
  7267. @noindent
  7268. (as usual, ignore the warnings about unknown keywords.)
  7269. @item
  7270. Let @var{size} be the size of the sparse member, @var{Bs} be its block number
  7271. and @var{Bn} be the block number of the next member.
  7272. Compute:
  7273. @smallexample
  7274. @var{N} = @var{Bs} - @var{Bn} - @var{size}/512 - 2
  7275. @end smallexample
  7276. @noindent
  7277. This number gives the size of the extended header part in tar @dfn{blocks}.
  7278. In our example, this formula gives: @code{897 - 56 - 425984 / 512 - 2
  7279. = 7}.
  7280. @item
  7281. Use @command{dd} to extract the headers:
  7282. @smallexample
  7283. @kbd{dd if=@var{archive} of=@var{hname} bs=512 skip=@var{Bs} count=@var{N}}
  7284. @end smallexample
  7285. @noindent
  7286. where @var{archive} is the archive name, @var{hname} is a name of the
  7287. file to store the extended header in, @var{Bs} and @var{N} are
  7288. computed in previous steps.
  7289. In our example, this command will be
  7290. @smallexample
  7291. $ @kbd{dd if=arc.tar of=xhdr bs=512 skip=56 count=7}
  7292. @end smallexample
  7293. @end enumerate
  7294. Finally, you can expand the condensed file, using the obtained header:
  7295. @smallexample
  7296. @group
  7297. $ @kbd{xsparse -v -x xhdr GNUSparseFile.6058/sparsefile}
  7298. Reading extended header file
  7299. Found variable GNU.sparse.size = 217481216
  7300. Found variable GNU.sparse.numblocks = 208
  7301. Found variable GNU.sparse.name = sparsefile
  7302. Found variable GNU.sparse.map = 0,2048,1050624,2048,@dots{}
  7303. Expanding file `GNUSparseFile.28124/sparsefile' to `sparsefile'
  7304. Done
  7305. @end group
  7306. @end smallexample
  7307. @node cpio
  7308. @section Comparison of @command{tar} and @command{cpio}
  7309. @UNREVISED
  7310. @FIXME{Reorganize the following material}
  7311. The @command{cpio} archive formats, like @command{tar}, do have maximum
  7312. file name lengths. The binary and old @acronym{ASCII} formats have a maximum file
  7313. length of 256, and the new @acronym{ASCII} and @acronym{CRC ASCII} formats have a max
  7314. file length of 1024. @acronym{GNU} @command{cpio} can read and write archives
  7315. with arbitrary file name lengths, but other @command{cpio} implementations
  7316. may crash unexplainedly trying to read them.
  7317. @command{tar} handles symbolic links in the form in which it comes in @acronym{BSD};
  7318. @command{cpio} doesn't handle symbolic links in the form in which it comes
  7319. in System V prior to SVR4, and some vendors may have added symlinks
  7320. to their system without enhancing @command{cpio} to know about them.
  7321. Others may have enhanced it in a way other than the way I did it
  7322. at Sun, and which was adopted by AT&T (and which is, I think, also
  7323. present in the @command{cpio} that Berkeley picked up from AT&T and put
  7324. into a later @acronym{BSD} release---I think I gave them my changes).
  7325. (SVR4 does some funny stuff with @command{tar}; basically, its @command{cpio}
  7326. can handle @command{tar} format input, and write it on output, and it
  7327. probably handles symbolic links. They may not have bothered doing
  7328. anything to enhance @command{tar} as a result.)
  7329. @command{cpio} handles special files; traditional @command{tar} doesn't.
  7330. @command{tar} comes with V7, System III, System V, and @acronym{BSD} source;
  7331. @command{cpio} comes only with System III, System V, and later @acronym{BSD}
  7332. (4.3-tahoe and later).
  7333. @command{tar}'s way of handling multiple hard links to a file can handle
  7334. file systems that support 32-bit inumbers (e.g., the @acronym{BSD} file system);
  7335. @command{cpio}s way requires you to play some games (in its ``binary''
  7336. format, i-numbers are only 16 bits, and in its ``portable @acronym{ASCII}'' format,
  7337. they're 18 bits---it would have to play games with the "file system @acronym{ID}"
  7338. field of the header to make sure that the file system @acronym{ID}/i-number pairs
  7339. of different files were always different), and I don't know which
  7340. @command{cpio}s, if any, play those games. Those that don't might get
  7341. confused and think two files are the same file when they're not, and
  7342. make hard links between them.
  7343. @command{tar}s way of handling multiple hard links to a file places only
  7344. one copy of the link on the tape, but the name attached to that copy
  7345. is the @emph{only} one you can use to retrieve the file; @command{cpio}s
  7346. way puts one copy for every link, but you can retrieve it using any
  7347. of the names.
  7348. @quotation
  7349. What type of check sum (if any) is used, and how is this calculated.
  7350. @end quotation
  7351. See the attached manual pages for @command{tar} and @command{cpio} format.
  7352. @command{tar} uses a checksum which is the sum of all the bytes in the
  7353. @command{tar} header for a file; @command{cpio} uses no checksum.
  7354. @quotation
  7355. If anyone knows why @command{cpio} was made when @command{tar} was present
  7356. at the unix scene,
  7357. @end quotation
  7358. It wasn't. @command{cpio} first showed up in PWB/UNIX 1.0; no
  7359. generally-available version of UNIX had @command{tar} at the time. I don't
  7360. know whether any version that was generally available @emph{within AT&T}
  7361. had @command{tar}, or, if so, whether the people within AT&T who did
  7362. @command{cpio} knew about it.
  7363. On restore, if there is a corruption on a tape @command{tar} will stop at
  7364. that point, while @command{cpio} will skip over it and try to restore the
  7365. rest of the files.
  7366. The main difference is just in the command syntax and header format.
  7367. @command{tar} is a little more tape-oriented in that everything is blocked
  7368. to start on a record boundary.
  7369. @quotation
  7370. Is there any differences between the ability to recover crashed
  7371. archives between the two of them. (Is there any chance of recovering
  7372. crashed archives at all.)
  7373. @end quotation
  7374. Theoretically it should be easier under @command{tar} since the blocking
  7375. lets you find a header with some variation of @samp{dd skip=@var{nn}}.
  7376. However, modern @command{cpio}'s and variations have an option to just
  7377. search for the next file header after an error with a reasonable chance
  7378. of resyncing. However, lots of tape driver software won't allow you to
  7379. continue past a media error which should be the only reason for getting
  7380. out of sync unless a file changed sizes while you were writing the
  7381. archive.
  7382. @quotation
  7383. If anyone knows why @command{cpio} was made when @command{tar} was present
  7384. at the unix scene, please tell me about this too.
  7385. @end quotation
  7386. Probably because it is more media efficient (by not blocking everything
  7387. and using only the space needed for the headers where @command{tar}
  7388. always uses 512 bytes per file header) and it knows how to archive
  7389. special files.
  7390. You might want to look at the freely available alternatives. The
  7391. major ones are @command{afio}, @GNUTAR{}, and
  7392. @command{pax}, each of which have their own extensions with some
  7393. backwards compatibility.
  7394. Sparse files were @command{tar}red as sparse files (which you can
  7395. easily test, because the resulting archive gets smaller, and
  7396. @acronym{GNU} @command{cpio} can no longer read it).
  7397. @node Media
  7398. @chapter Tapes and Other Archive Media
  7399. @UNREVISED
  7400. A few special cases about tape handling warrant more detailed
  7401. description. These special cases are discussed below.
  7402. Many complexities surround the use of @command{tar} on tape drives. Since
  7403. the creation and manipulation of archives located on magnetic tape was
  7404. the original purpose of @command{tar}, it contains many features making
  7405. such manipulation easier.
  7406. Archives are usually written on dismountable media---tape cartridges,
  7407. mag tapes, or floppy disks.
  7408. The amount of data a tape or disk holds depends not only on its size,
  7409. but also on how it is formatted. A 2400 foot long reel of mag tape
  7410. holds 40 megabytes of data when formatted at 1600 bits per inch. The
  7411. physically smaller EXABYTE tape cartridge holds 2.3 gigabytes.
  7412. Magnetic media are re-usable---once the archive on a tape is no longer
  7413. needed, the archive can be erased and the tape or disk used over.
  7414. Media quality does deteriorate with use, however. Most tapes or disks
  7415. should be discarded when they begin to produce data errors. EXABYTE
  7416. tape cartridges should be discarded when they generate an @dfn{error
  7417. count} (number of non-usable bits) of more than 10k.
  7418. Magnetic media are written and erased using magnetic fields, and
  7419. should be protected from such fields to avoid damage to stored data.
  7420. Sticking a floppy disk to a filing cabinet using a magnet is probably
  7421. not a good idea.
  7422. @menu
  7423. * Device:: Device selection and switching
  7424. * Remote Tape Server::
  7425. * Common Problems and Solutions::
  7426. * Blocking:: Blocking
  7427. * Many:: Many archives on one tape
  7428. * Using Multiple Tapes:: Using Multiple Tapes
  7429. * label:: Including a Label in the Archive
  7430. * verify::
  7431. * Write Protection::
  7432. @end menu
  7433. @node Device
  7434. @section Device Selection and Switching
  7435. @UNREVISED
  7436. @table @option
  7437. @item -f [@var{hostname}:]@var{file}
  7438. @itemx --file=[@var{hostname}:]@var{file}
  7439. Use archive file or device @var{file} on @var{hostname}.
  7440. @end table
  7441. This option is used to specify the file name of the archive @command{tar}
  7442. works on.
  7443. If the file name is @samp{-}, @command{tar} reads the archive from standard
  7444. input (when listing or extracting), or writes it to standard output
  7445. (when creating). If the @samp{-} file name is given when updating an
  7446. archive, @command{tar} will read the original archive from its standard
  7447. input, and will write the entire new archive to its standard output.
  7448. If the file name contains a @samp{:}, it is interpreted as
  7449. @samp{hostname:file name}. If the @var{hostname} contains an @dfn{at}
  7450. sign (@samp{@@}), it is treated as @samp{user@@hostname:file name}. In
  7451. either case, @command{tar} will invoke the command @command{rsh} (or
  7452. @command{remsh}) to start up an @command{/usr/libexec/rmt} on the remote
  7453. machine. If you give an alternate login name, it will be given to the
  7454. @command{rsh}.
  7455. Naturally, the remote machine must have an executable
  7456. @command{/usr/libexec/rmt}. This program is free software from the
  7457. University of California, and a copy of the source code can be found
  7458. with the sources for @command{tar}; it's compiled and installed by default.
  7459. The exact path to this utility is determined when configuring the package.
  7460. It is @file{@var{prefix}/libexec/rmt}, where @var{prefix} stands for
  7461. your installation prefix. This location may also be overridden at
  7462. runtime by using @option{rmt-command=@var{command}} option (@xref{Option Summary,
  7463. ---rmt-command}, for detailed description of this option. @xref{Remote
  7464. Tape Server}, for the description of @command{rmt} command).
  7465. If this option is not given, but the environment variable @env{TAPE}
  7466. is set, its value is used; otherwise, old versions of @command{tar}
  7467. used a default archive name (which was picked when @command{tar} was
  7468. compiled). The default is normally set up to be the @dfn{first} tape
  7469. drive or other transportable I/O medium on the system.
  7470. Starting with version 1.11.5, @GNUTAR{} uses
  7471. standard input and standard output as the default device, and I will
  7472. not try anymore supporting automatic device detection at installation
  7473. time. This was failing really in too many cases, it was hopeless.
  7474. This is now completely left to the installer to override standard
  7475. input and standard output for default device, if this seems
  7476. preferable. Further, I think @emph{most} actual usages of
  7477. @command{tar} are done with pipes or disks, not really tapes,
  7478. cartridges or diskettes.
  7479. Some users think that using standard input and output is running
  7480. after trouble. This could lead to a nasty surprise on your screen if
  7481. you forget to specify an output file name---especially if you are going
  7482. through a network or terminal server capable of buffering large amounts
  7483. of output. We had so many bug reports in that area of configuring
  7484. default tapes automatically, and so many contradicting requests, that
  7485. we finally consider the problem to be portably intractable. We could
  7486. of course use something like @samp{/dev/tape} as a default, but this
  7487. is @emph{also} running after various kind of trouble, going from hung
  7488. processes to accidental destruction of real tapes. After having seen
  7489. all this mess, using standard input and output as a default really
  7490. sounds like the only clean choice left, and a very useful one too.
  7491. @GNUTAR{} reads and writes archive in records, I
  7492. suspect this is the main reason why block devices are preferred over
  7493. character devices. Most probably, block devices are more efficient
  7494. too. The installer could also check for @samp{DEFTAPE} in
  7495. @file{<sys/mtio.h>}.
  7496. @table @option
  7497. @xopindex{force-local, short description}
  7498. @item --force-local
  7499. Archive file is local even if it contains a colon.
  7500. @opindex rsh-command
  7501. @item --rsh-command=@var{command}
  7502. Use remote @var{command} instead of @command{rsh}. This option exists
  7503. so that people who use something other than the standard @command{rsh}
  7504. (e.g., a Kerberized @command{rsh}) can access a remote device.
  7505. When this command is not used, the shell command found when
  7506. the @command{tar} program was installed is used instead. This is
  7507. the first found of @file{/usr/ucb/rsh}, @file{/usr/bin/remsh},
  7508. @file{/usr/bin/rsh}, @file{/usr/bsd/rsh} or @file{/usr/bin/nsh}.
  7509. The installer may have overridden this by defining the environment
  7510. variable @env{RSH} @emph{at installation time}.
  7511. @item -[0-7][lmh]
  7512. Specify drive and density.
  7513. @xopindex{multi-volume, short description}
  7514. @item -M
  7515. @itemx --multi-volume
  7516. Create/list/extract multi-volume archive.
  7517. This option causes @command{tar} to write a @dfn{multi-volume} archive---one
  7518. that may be larger than will fit on the medium used to hold it.
  7519. @xref{Multi-Volume Archives}.
  7520. @xopindex{tape-length, short description}
  7521. @item -L @var{num}
  7522. @itemx --tape-length=@var{num}
  7523. Change tape after writing @var{num} x 1024 bytes.
  7524. This option might be useful when your tape drivers do not properly
  7525. detect end of physical tapes. By being slightly conservative on the
  7526. maximum tape length, you might avoid the problem entirely.
  7527. @xopindex{info-script, short description}
  7528. @xopindex{new-volume-script, short description}
  7529. @item -F @var{file}
  7530. @itemx --info-script=@var{file}
  7531. @itemx --new-volume-script=@var{file}
  7532. Execute @file{file} at end of each tape. This implies
  7533. @option{--multi-volume} (@option{-M}). @xref{info-script}, for a detailed
  7534. description of this option.
  7535. @end table
  7536. @node Remote Tape Server
  7537. @section The Remote Tape Server
  7538. @cindex remote tape drive
  7539. @pindex rmt
  7540. In order to access the tape drive on a remote machine, @command{tar}
  7541. uses the remote tape server written at the University of California at
  7542. Berkeley. The remote tape server must be installed as
  7543. @file{@var{prefix}/libexec/rmt} on any machine whose tape drive you
  7544. want to use. @command{tar} calls @command{rmt} by running an
  7545. @command{rsh} or @command{remsh} to the remote machine, optionally
  7546. using a different login name if one is supplied.
  7547. A copy of the source for the remote tape server is provided. It is
  7548. Copyright @copyright{} 1983 by the Regents of the University of
  7549. California, but can be freely distributed. It is compiled and
  7550. installed by default.
  7551. @cindex absolute file names
  7552. Unless you use the @option{--absolute-names} (@option{-P}) option,
  7553. @GNUTAR{} will not allow you to create an archive that contains
  7554. absolute file names (a file name beginning with @samp{/}.) If you try,
  7555. @command{tar} will automatically remove the leading @samp{/} from the
  7556. file names it stores in the archive. It will also type a warning
  7557. message telling you what it is doing.
  7558. When reading an archive that was created with a different
  7559. @command{tar} program, @GNUTAR{} automatically
  7560. extracts entries in the archive which have absolute file names as if
  7561. the file names were not absolute. This is an important feature. A
  7562. visitor here once gave a @command{tar} tape to an operator to restore;
  7563. the operator used Sun @command{tar} instead of @GNUTAR{},
  7564. and the result was that it replaced large portions of
  7565. our @file{/bin} and friends with versions from the tape; needless to
  7566. say, we were unhappy about having to recover the file system from
  7567. backup tapes.
  7568. For example, if the archive contained a file @file{/usr/bin/computoy},
  7569. @GNUTAR{} would extract the file to @file{usr/bin/computoy},
  7570. relative to the current directory. If you want to extract the files in
  7571. an archive to the same absolute names that they had when the archive
  7572. was created, you should do a @samp{cd /} before extracting the files
  7573. from the archive, or you should either use the @option{--absolute-names}
  7574. option, or use the command @samp{tar -C / @dots{}}.
  7575. @cindex Ultrix 3.1 and write failure
  7576. Some versions of Unix (Ultrix 3.1 is known to have this problem),
  7577. can claim that a short write near the end of a tape succeeded,
  7578. when it actually failed. This will result in the -M option not
  7579. working correctly. The best workaround at the moment is to use a
  7580. significantly larger blocking factor than the default 20.
  7581. In order to update an archive, @command{tar} must be able to backspace the
  7582. archive in order to reread or rewrite a record that was just read (or
  7583. written). This is currently possible only on two kinds of files: normal
  7584. disk files (or any other file that can be backspaced with @samp{lseek}),
  7585. and industry-standard 9-track magnetic tape (or any other kind of tape
  7586. that can be backspaced with the @code{MTIOCTOP} @code{ioctl}.
  7587. This means that the @option{--append}, @option{--concatenate}, and
  7588. @option{--delete} commands will not work on any other kind of file.
  7589. Some media simply cannot be backspaced, which means these commands and
  7590. options will never be able to work on them. These non-backspacing
  7591. media include pipes and cartridge tape drives.
  7592. Some other media can be backspaced, and @command{tar} will work on them
  7593. once @command{tar} is modified to do so.
  7594. Archives created with the @option{--multi-volume}, @option{--label}, and
  7595. @option{--incremental} (@option{-G}) options may not be readable by other version
  7596. of @command{tar}. In particular, restoring a file that was split over
  7597. a volume boundary will require some careful work with @command{dd}, if
  7598. it can be done at all. Other versions of @command{tar} may also create
  7599. an empty file whose name is that of the volume header. Some versions
  7600. of @command{tar} may create normal files instead of directories archived
  7601. with the @option{--incremental} (@option{-G}) option.
  7602. @node Common Problems and Solutions
  7603. @section Some Common Problems and their Solutions
  7604. @ifclear PUBLISH
  7605. @format
  7606. errors from system:
  7607. permission denied
  7608. no such file or directory
  7609. not owner
  7610. errors from @command{tar}:
  7611. directory checksum error
  7612. header format error
  7613. errors from media/system:
  7614. i/o error
  7615. device busy
  7616. @end format
  7617. @end ifclear
  7618. @node Blocking
  7619. @section Blocking
  7620. @UNREVISED
  7621. @dfn{Block} and @dfn{record} terminology is rather confused, and it
  7622. is also confusing to the expert reader. On the other hand, readers
  7623. who are new to the field have a fresh mind, and they may safely skip
  7624. the next two paragraphs, as the remainder of this manual uses those
  7625. two terms in a quite consistent way.
  7626. John Gilmore, the writer of the public domain @command{tar} from which
  7627. @GNUTAR{} was originally derived, wrote (June 1995):
  7628. @quotation
  7629. The nomenclature of tape drives comes from IBM, where I believe
  7630. they were invented for the IBM 650 or so. On IBM mainframes, what
  7631. is recorded on tape are tape blocks. The logical organization of
  7632. data is into records. There are various ways of putting records into
  7633. blocks, including @code{F} (fixed sized records), @code{V} (variable
  7634. sized records), @code{FB} (fixed blocked: fixed size records, @var{n}
  7635. to a block), @code{VB} (variable size records, @var{n} to a block),
  7636. @code{VSB} (variable spanned blocked: variable sized records that can
  7637. occupy more than one block), etc. The @code{JCL} @samp{DD RECFORM=}
  7638. parameter specified this to the operating system.
  7639. The Unix man page on @command{tar} was totally confused about this.
  7640. When I wrote @code{PD TAR}, I used the historically correct terminology
  7641. (@command{tar} writes data records, which are grouped into blocks).
  7642. It appears that the bogus terminology made it into @acronym{POSIX} (no surprise
  7643. here), and now Fran@,{c}ois has migrated that terminology back
  7644. into the source code too.
  7645. @end quotation
  7646. The term @dfn{physical block} means the basic transfer chunk from or
  7647. to a device, after which reading or writing may stop without anything
  7648. being lost. In this manual, the term @dfn{block} usually refers to
  7649. a disk physical block, @emph{assuming} that each disk block is 512
  7650. bytes in length. It is true that some disk devices have different
  7651. physical blocks, but @command{tar} ignore these differences in its own
  7652. format, which is meant to be portable, so a @command{tar} block is always
  7653. 512 bytes in length, and @dfn{block} always mean a @command{tar} block.
  7654. The term @dfn{logical block} often represents the basic chunk of
  7655. allocation of many disk blocks as a single entity, which the operating
  7656. system treats somewhat atomically; this concept is only barely used
  7657. in @GNUTAR{}.
  7658. The term @dfn{physical record} is another way to speak of a physical
  7659. block, those two terms are somewhat interchangeable. In this manual,
  7660. the term @dfn{record} usually refers to a tape physical block,
  7661. @emph{assuming} that the @command{tar} archive is kept on magnetic tape.
  7662. It is true that archives may be put on disk or used with pipes,
  7663. but nevertheless, @command{tar} tries to read and write the archive one
  7664. @dfn{record} at a time, whatever the medium in use. One record is made
  7665. up of an integral number of blocks, and this operation of putting many
  7666. disk blocks into a single tape block is called @dfn{reblocking}, or
  7667. more simply, @dfn{blocking}. The term @dfn{logical record} refers to
  7668. the logical organization of many characters into something meaningful
  7669. to the application. The term @dfn{unit record} describes a small set
  7670. of characters which are transmitted whole to or by the application,
  7671. and often refers to a line of text. Those two last terms are unrelated
  7672. to what we call a @dfn{record} in @GNUTAR{}.
  7673. When writing to tapes, @command{tar} writes the contents of the archive
  7674. in chunks known as @dfn{records}. To change the default blocking
  7675. factor, use the @option{--blocking-factor=@var{512-size}} (@option{-b
  7676. @var{512-size}}) option. Each record will then be composed of
  7677. @var{512-size} blocks. (Each @command{tar} block is 512 bytes.
  7678. @xref{Standard}.) Each file written to the archive uses at least one
  7679. full record. As a result, using a larger record size can result in
  7680. more wasted space for small files. On the other hand, a larger record
  7681. size can often be read and written much more efficiently.
  7682. Further complicating the problem is that some tape drives ignore the
  7683. blocking entirely. For these, a larger record size can still improve
  7684. performance (because the software layers above the tape drive still
  7685. honor the blocking), but not as dramatically as on tape drives that
  7686. honor blocking.
  7687. When reading an archive, @command{tar} can usually figure out the
  7688. record size on itself. When this is the case, and a non-standard
  7689. record size was used when the archive was created, @command{tar} will
  7690. print a message about a non-standard blocking factor, and then operate
  7691. normally. On some tape devices, however, @command{tar} cannot figure
  7692. out the record size itself. On most of those, you can specify a
  7693. blocking factor (with @option{--blocking-factor}) larger than the
  7694. actual blocking factor, and then use the @option{--read-full-records}
  7695. (@option{-B}) option. (If you specify a blocking factor with
  7696. @option{--blocking-factor} and don't use the
  7697. @option{--read-full-records} option, then @command{tar} will not
  7698. attempt to figure out the recording size itself.) On some devices,
  7699. you must always specify the record size exactly with
  7700. @option{--blocking-factor} when reading, because @command{tar} cannot
  7701. figure it out. In any case, use @option{--list} (@option{-t}) before
  7702. doing any extractions to see whether @command{tar} is reading the archive
  7703. correctly.
  7704. @command{tar} blocks are all fixed size (512 bytes), and its scheme for
  7705. putting them into records is to put a whole number of them (one or
  7706. more) into each record. @command{tar} records are all the same size;
  7707. at the end of the file there's a block containing all zeros, which
  7708. is how you tell that the remainder of the last record(s) are garbage.
  7709. In a standard @command{tar} file (no options), the block size is 512
  7710. and the record size is 10240, for a blocking factor of 20. What the
  7711. @option{--blocking-factor} option does is sets the blocking factor,
  7712. changing the record size while leaving the block size at 512 bytes.
  7713. 20 was fine for ancient 800 or 1600 bpi reel-to-reel tape drives;
  7714. most tape drives these days prefer much bigger records in order to
  7715. stream and not waste tape. When writing tapes for myself, some tend
  7716. to use a factor of the order of 2048, say, giving a record size of
  7717. around one megabyte.
  7718. If you use a blocking factor larger than 20, older @command{tar}
  7719. programs might not be able to read the archive, so we recommend this
  7720. as a limit to use in practice. @GNUTAR{}, however,
  7721. will support arbitrarily large record sizes, limited only by the
  7722. amount of virtual memory or the physical characteristics of the tape
  7723. device.
  7724. @menu
  7725. * Format Variations:: Format Variations
  7726. * Blocking Factor:: The Blocking Factor of an Archive
  7727. @end menu
  7728. @node Format Variations
  7729. @subsection Format Variations
  7730. @cindex Format Parameters
  7731. @cindex Format Options
  7732. @cindex Options, archive format specifying
  7733. @cindex Options, format specifying
  7734. @UNREVISED
  7735. Format parameters specify how an archive is written on the archive
  7736. media. The best choice of format parameters will vary depending on
  7737. the type and number of files being archived, and on the media used to
  7738. store the archive.
  7739. To specify format parameters when accessing or creating an archive,
  7740. you can use the options described in the following sections.
  7741. If you do not specify any format parameters, @command{tar} uses
  7742. default parameters. You cannot modify a compressed archive.
  7743. If you create an archive with the @option{--blocking-factor} option
  7744. specified (@pxref{Blocking Factor}), you must specify that
  7745. blocking-factor when operating on the archive. @xref{Formats}, for other
  7746. examples of format parameter considerations.
  7747. @node Blocking Factor
  7748. @subsection The Blocking Factor of an Archive
  7749. @cindex Blocking Factor
  7750. @cindex Record Size
  7751. @cindex Number of blocks per record
  7752. @cindex Number of bytes per record
  7753. @cindex Bytes per record
  7754. @cindex Blocks per record
  7755. @UNREVISED
  7756. @opindex blocking-factor
  7757. The data in an archive is grouped into blocks, which are 512 bytes.
  7758. Blocks are read and written in whole number multiples called
  7759. @dfn{records}. The number of blocks in a record (i.e., the size of a
  7760. record in units of 512 bytes) is called the @dfn{blocking factor}.
  7761. The @option{--blocking-factor=@var{512-size}} (@option{-b
  7762. @var{512-size}}) option specifies the blocking factor of an archive.
  7763. The default blocking factor is typically 20 (i.e., 10240 bytes), but
  7764. can be specified at installation. To find out the blocking factor of
  7765. an existing archive, use @samp{tar --list --file=@var{archive-name}}.
  7766. This may not work on some devices.
  7767. Records are separated by gaps, which waste space on the archive media.
  7768. If you are archiving on magnetic tape, using a larger blocking factor
  7769. (and therefore larger records) provides faster throughput and allows you
  7770. to fit more data on a tape (because there are fewer gaps). If you are
  7771. archiving on cartridge, a very large blocking factor (say 126 or more)
  7772. greatly increases performance. A smaller blocking factor, on the other
  7773. hand, may be useful when archiving small files, to avoid archiving lots
  7774. of nulls as @command{tar} fills out the archive to the end of the record.
  7775. In general, the ideal record size depends on the size of the
  7776. inter-record gaps on the tape you are using, and the average size of the
  7777. files you are archiving. @xref{create}, for information on
  7778. writing archives.
  7779. @FIXME{Need example of using a cartridge with blocking factor=126 or more.}
  7780. Archives with blocking factors larger than 20 cannot be read
  7781. by very old versions of @command{tar}, or by some newer versions
  7782. of @command{tar} running on old machines with small address spaces.
  7783. With @GNUTAR{}, the blocking factor of an archive is limited
  7784. only by the maximum record size of the device containing the archive,
  7785. or by the amount of available virtual memory.
  7786. Also, on some systems, not using adequate blocking factors, as sometimes
  7787. imposed by the device drivers, may yield unexpected diagnostics. For
  7788. example, this has been reported:
  7789. @smallexample
  7790. Cannot write to /dev/dlt: Invalid argument
  7791. @end smallexample
  7792. @noindent
  7793. In such cases, it sometimes happen that the @command{tar} bundled by
  7794. the system is aware of block size idiosyncrasies, while @GNUTAR{}
  7795. requires an explicit specification for the block size,
  7796. which it cannot guess. This yields some people to consider
  7797. @GNUTAR{} is misbehaving, because by comparison,
  7798. @cite{the bundle @command{tar} works OK}. Adding @w{@kbd{-b 256}},
  7799. for example, might resolve the problem.
  7800. If you use a non-default blocking factor when you create an archive, you
  7801. must specify the same blocking factor when you modify that archive. Some
  7802. archive devices will also require you to specify the blocking factor when
  7803. reading that archive, however this is not typically the case. Usually, you
  7804. can use @option{--list} (@option{-t}) without specifying a blocking factor---@command{tar}
  7805. reports a non-default record size and then lists the archive members as
  7806. it would normally. To extract files from an archive with a non-standard
  7807. blocking factor (particularly if you're not sure what the blocking factor
  7808. is), you can usually use the @option{--read-full-records} (@option{-B}) option while
  7809. specifying a blocking factor larger then the blocking factor of the archive
  7810. (i.e., @samp{tar --extract --read-full-records --blocking-factor=300}.
  7811. @xref{list}, for more information on the @option{--list} (@option{-t})
  7812. operation. @xref{Reading}, for a more detailed explanation of that option.
  7813. @table @option
  7814. @item --blocking-factor=@var{number}
  7815. @itemx -b @var{number}
  7816. Specifies the blocking factor of an archive. Can be used with any
  7817. operation, but is usually not necessary with @option{--list} (@option{-t}).
  7818. @end table
  7819. Device blocking
  7820. @table @option
  7821. @item -b @var{blocks}
  7822. @itemx --blocking-factor=@var{blocks}
  7823. Set record size to @math{@var{blocks} * 512} bytes.
  7824. This option is used to specify a @dfn{blocking factor} for the archive.
  7825. When reading or writing the archive, @command{tar}, will do reads and writes
  7826. of the archive in records of @math{@var{block}*512} bytes. This is true
  7827. even when the archive is compressed. Some devices requires that all
  7828. write operations be a multiple of a certain size, and so, @command{tar}
  7829. pads the archive out to the next record boundary.
  7830. The default blocking factor is set when @command{tar} is compiled, and is
  7831. typically 20. Blocking factors larger than 20 cannot be read by very
  7832. old versions of @command{tar}, or by some newer versions of @command{tar}
  7833. running on old machines with small address spaces.
  7834. With a magnetic tape, larger records give faster throughput and fit
  7835. more data on a tape (because there are fewer inter-record gaps).
  7836. If the archive is in a disk file or a pipe, you may want to specify
  7837. a smaller blocking factor, since a large one will result in a large
  7838. number of null bytes at the end of the archive.
  7839. When writing cartridge or other streaming tapes, a much larger
  7840. blocking factor (say 126 or more) will greatly increase performance.
  7841. However, you must specify the same blocking factor when reading or
  7842. updating the archive.
  7843. Apparently, Exabyte drives have a physical block size of 8K bytes.
  7844. If we choose our blocksize as a multiple of 8k bytes, then the problem
  7845. seems to disappear. Id est, we are using block size of 112 right
  7846. now, and we haven't had the problem since we switched@dots{}
  7847. With @GNUTAR{} the blocking factor is limited only
  7848. by the maximum record size of the device containing the archive, or by
  7849. the amount of available virtual memory.
  7850. However, deblocking or reblocking is virtually avoided in a special
  7851. case which often occurs in practice, but which requires all the
  7852. following conditions to be simultaneously true:
  7853. @itemize @bullet
  7854. @item
  7855. the archive is subject to a compression option,
  7856. @item
  7857. the archive is not handled through standard input or output, nor
  7858. redirected nor piped,
  7859. @item
  7860. the archive is directly handled to a local disk, instead of any special
  7861. device,
  7862. @item
  7863. @option{--blocking-factor} is not explicitly specified on the @command{tar}
  7864. invocation.
  7865. @end itemize
  7866. If the output goes directly to a local disk, and not through
  7867. stdout, then the last write is not extended to a full record size.
  7868. Otherwise, reblocking occurs. Here are a few other remarks on this
  7869. topic:
  7870. @itemize @bullet
  7871. @item
  7872. @command{gzip} will complain about trailing garbage if asked to
  7873. uncompress a compressed archive on tape, there is an option to turn
  7874. the message off, but it breaks the regularity of simply having to use
  7875. @samp{@var{prog} -d} for decompression. It would be nice if gzip was
  7876. silently ignoring any number of trailing zeros. I'll ask Jean-loup
  7877. Gailly, by sending a copy of this message to him.
  7878. @item
  7879. @command{compress} does not show this problem, but as Jean-loup pointed
  7880. out to Michael, @samp{compress -d} silently adds garbage after
  7881. the result of decompression, which tar ignores because it already
  7882. recognized its end-of-file indicator. So this bug may be safely
  7883. ignored.
  7884. @item
  7885. @samp{gzip -d -q} will be silent about the trailing zeros indeed,
  7886. but will still return an exit status of 2 which tar reports in turn.
  7887. @command{tar} might ignore the exit status returned, but I hate doing
  7888. that, as it weakens the protection @command{tar} offers users against
  7889. other possible problems at decompression time. If @command{gzip} was
  7890. silently skipping trailing zeros @emph{and} also avoiding setting the
  7891. exit status in this innocuous case, that would solve this situation.
  7892. @item
  7893. @command{tar} should become more solid at not stopping to read a pipe at
  7894. the first null block encountered. This inelegantly breaks the pipe.
  7895. @command{tar} should rather drain the pipe out before exiting itself.
  7896. @end itemize
  7897. @xopindex{ignore-zeros, short description}
  7898. @item -i
  7899. @itemx --ignore-zeros
  7900. Ignore blocks of zeros in archive (means EOF).
  7901. The @option{--ignore-zeros} (@option{-i}) option causes @command{tar} to ignore blocks
  7902. of zeros in the archive. Normally a block of zeros indicates the
  7903. end of the archive, but when reading a damaged archive, or one which
  7904. was created by concatenating several archives together, this option
  7905. allows @command{tar} to read the entire archive. This option is not on
  7906. by default because many versions of @command{tar} write garbage after
  7907. the zeroed blocks.
  7908. Note that this option causes @command{tar} to read to the end of the
  7909. archive file, which may sometimes avoid problems when multiple files
  7910. are stored on a single physical tape.
  7911. @xopindex{read-full-records, short description}
  7912. @item -B
  7913. @itemx --read-full-records
  7914. Reblock as we read (for reading 4.2@acronym{BSD} pipes).
  7915. If @option{--read-full-records} is used, @command{tar}
  7916. will not panic if an attempt to read a record from the archive does
  7917. not return a full record. Instead, @command{tar} will keep reading
  7918. until it has obtained a full
  7919. record.
  7920. This option is turned on by default when @command{tar} is reading
  7921. an archive from standard input, or from a remote machine. This is
  7922. because on @acronym{BSD} Unix systems, a read of a pipe will return however
  7923. much happens to be in the pipe, even if it is less than @command{tar}
  7924. requested. If this option was not used, @command{tar} would fail as
  7925. soon as it read an incomplete record from the pipe.
  7926. This option is also useful with the commands for updating an archive.
  7927. @end table
  7928. Tape blocking
  7929. @FIXME{Appropriate options should be moved here from elsewhere.}
  7930. @cindex blocking factor
  7931. @cindex tape blocking
  7932. When handling various tapes or cartridges, you have to take care of
  7933. selecting a proper blocking, that is, the number of disk blocks you
  7934. put together as a single tape block on the tape, without intervening
  7935. tape gaps. A @dfn{tape gap} is a small landing area on the tape
  7936. with no information on it, used for decelerating the tape to a
  7937. full stop, and for later regaining the reading or writing speed.
  7938. When the tape driver starts reading a record, the record has to
  7939. be read whole without stopping, as a tape gap is needed to stop the
  7940. tape motion without loosing information.
  7941. @cindex Exabyte blocking
  7942. @cindex DAT blocking
  7943. Using higher blocking (putting more disk blocks per tape block) will use
  7944. the tape more efficiently as there will be less tape gaps. But reading
  7945. such tapes may be more difficult for the system, as more memory will be
  7946. required to receive at once the whole record. Further, if there is a
  7947. reading error on a huge record, this is less likely that the system will
  7948. succeed in recovering the information. So, blocking should not be too
  7949. low, nor it should be too high. @command{tar} uses by default a blocking of
  7950. 20 for historical reasons, and it does not really matter when reading or
  7951. writing to disk. Current tape technology would easily accommodate higher
  7952. blockings. Sun recommends a blocking of 126 for Exabytes and 96 for DATs.
  7953. We were told that for some DLT drives, the blocking should be a multiple
  7954. of 4Kb, preferably 64Kb (@w{@kbd{-b 128}}) or 256 for decent performance.
  7955. Other manufacturers may use different recommendations for the same tapes.
  7956. This might also depends of the buffering techniques used inside modern
  7957. tape controllers. Some imposes a minimum blocking, or a maximum blocking.
  7958. Others request blocking to be some exponent of two.
  7959. So, there is no fixed rule for blocking. But blocking at read time
  7960. should ideally be the same as blocking used at write time. At one place
  7961. I know, with a wide variety of equipment, they found it best to use a
  7962. blocking of 32 to guarantee that their tapes are fully interchangeable.
  7963. I was also told that, for recycled tapes, prior erasure (by the same
  7964. drive unit that will be used to create the archives) sometimes lowers
  7965. the error rates observed at rewriting time.
  7966. I might also use @option{--number-blocks} instead of
  7967. @option{--block-number}, so @option{--block} will then expand to
  7968. @option{--blocking-factor} unambiguously.
  7969. @node Many
  7970. @section Many Archives on One Tape
  7971. @FIXME{Appropriate options should be moved here from elsewhere.}
  7972. @findex ntape @r{device}
  7973. Most tape devices have two entries in the @file{/dev} directory, or
  7974. entries that come in pairs, which differ only in the minor number for
  7975. this device. Let's take for example @file{/dev/tape}, which often
  7976. points to the only or usual tape device of a given system. There might
  7977. be a corresponding @file{/dev/nrtape} or @file{/dev/ntape}. The simpler
  7978. name is the @emph{rewinding} version of the device, while the name
  7979. having @samp{nr} in it is the @emph{no rewinding} version of the same
  7980. device.
  7981. A rewinding tape device will bring back the tape to its beginning point
  7982. automatically when this device is opened or closed. Since @command{tar}
  7983. opens the archive file before using it and closes it afterwards, this
  7984. means that a simple:
  7985. @smallexample
  7986. $ @kbd{tar cf /dev/tape @var{directory}}
  7987. @end smallexample
  7988. @noindent
  7989. will reposition the tape to its beginning both prior and after saving
  7990. @var{directory} contents to it, thus erasing prior tape contents and
  7991. making it so that any subsequent write operation will destroy what has
  7992. just been saved.
  7993. @cindex tape positioning
  7994. So, a rewinding device is normally meant to hold one and only one file.
  7995. If you want to put more than one @command{tar} archive on a given tape, you
  7996. will need to avoid using the rewinding version of the tape device. You
  7997. will also have to pay special attention to tape positioning. Errors in
  7998. positioning may overwrite the valuable data already on your tape. Many
  7999. people, burnt by past experiences, will only use rewinding devices and
  8000. limit themselves to one file per tape, precisely to avoid the risk of
  8001. such errors. Be fully aware that writing at the wrong position on a
  8002. tape loses all information past this point and most probably until the
  8003. end of the tape, and this destroyed information @emph{cannot} be
  8004. recovered.
  8005. To save @var{directory-1} as a first archive at the beginning of a
  8006. tape, and leave that tape ready for a second archive, you should use:
  8007. @smallexample
  8008. $ @kbd{mt -f /dev/nrtape rewind}
  8009. $ @kbd{tar cf /dev/nrtape @var{directory-1}}
  8010. @end smallexample
  8011. @cindex tape marks
  8012. @dfn{Tape marks} are special magnetic patterns written on the tape
  8013. media, which are later recognizable by the reading hardware. These
  8014. marks are used after each file, when there are many on a single tape.
  8015. An empty file (that is to say, two tape marks in a row) signal the
  8016. logical end of the tape, after which no file exist. Usually,
  8017. non-rewinding tape device drivers will react to the close request issued
  8018. by @command{tar} by first writing two tape marks after your archive, and by
  8019. backspacing over one of these. So, if you remove the tape at that time
  8020. from the tape drive, it is properly terminated. But if you write
  8021. another file at the current position, the second tape mark will be
  8022. erased by the new information, leaving only one tape mark between files.
  8023. So, you may now save @var{directory-2} as a second archive after the
  8024. first on the same tape by issuing the command:
  8025. @smallexample
  8026. $ @kbd{tar cf /dev/nrtape @var{directory-2}}
  8027. @end smallexample
  8028. @noindent
  8029. and so on for all the archives you want to put on the same tape.
  8030. Another usual case is that you do not write all the archives the same
  8031. day, and you need to remove and store the tape between two archive
  8032. sessions. In general, you must remember how many files are already
  8033. saved on your tape. Suppose your tape already has 16 files on it, and
  8034. that you are ready to write the 17th. You have to take care of skipping
  8035. the first 16 tape marks before saving @var{directory-17}, say, by using
  8036. these commands:
  8037. @smallexample
  8038. $ @kbd{mt -f /dev/nrtape rewind}
  8039. $ @kbd{mt -f /dev/nrtape fsf 16}
  8040. $ @kbd{tar cf /dev/nrtape @var{directory-17}}
  8041. @end smallexample
  8042. In all the previous examples, we put aside blocking considerations, but
  8043. you should do the proper things for that as well. @xref{Blocking}.
  8044. @menu
  8045. * Tape Positioning:: Tape Positions and Tape Marks
  8046. * mt:: The @command{mt} Utility
  8047. @end menu
  8048. @node Tape Positioning
  8049. @subsection Tape Positions and Tape Marks
  8050. @UNREVISED
  8051. Just as archives can store more than one file from the file system,
  8052. tapes can store more than one archive file. To keep track of where
  8053. archive files (or any other type of file stored on tape) begin and
  8054. end, tape archive devices write magnetic @dfn{tape marks} on the
  8055. archive media. Tape drives write one tape mark between files,
  8056. two at the end of all the file entries.
  8057. If you think of data as a series of records "rrrr"'s, and tape marks as
  8058. "*"'s, a tape might look like the following:
  8059. @smallexample
  8060. rrrr*rrrrrr*rrrrr*rr*rrrrr**-------------------------
  8061. @end smallexample
  8062. Tape devices read and write tapes using a read/write @dfn{tape
  8063. head}---a physical part of the device which can only access one
  8064. point on the tape at a time. When you use @command{tar} to read or
  8065. write archive data from a tape device, the device will begin reading
  8066. or writing from wherever on the tape the tape head happens to be,
  8067. regardless of which archive or what part of the archive the tape
  8068. head is on. Before writing an archive, you should make sure that no
  8069. data on the tape will be overwritten (unless it is no longer needed).
  8070. Before reading an archive, you should make sure the tape head is at
  8071. the beginning of the archive you want to read. You can do it manually
  8072. via @code{mt} utility (@pxref{mt}). The @code{restore} script does
  8073. that automatically (@pxref{Scripted Restoration}).
  8074. If you want to add new archive file entries to a tape, you should
  8075. advance the tape to the end of the existing file entries, backspace
  8076. over the last tape mark, and write the new archive file. If you were
  8077. to add two archives to the example above, the tape might look like the
  8078. following:
  8079. @smallexample
  8080. rrrr*rrrrrr*rrrrr*rr*rrrrr*rrr*rrrr**----------------
  8081. @end smallexample
  8082. @node mt
  8083. @subsection The @command{mt} Utility
  8084. @UNREVISED
  8085. @FIXME{Is it true that this only works on non-block devices?
  8086. should explain the difference, (fixed or variable).}
  8087. @xref{Blocking Factor}.
  8088. You can use the @command{mt} utility to advance or rewind a tape past a
  8089. specified number of archive files on the tape. This will allow you
  8090. to move to the beginning of an archive before extracting or reading
  8091. it, or to the end of all the archives before writing a new one.
  8092. @FIXME{Why isn't there an "advance 'til you find two tape marks
  8093. together"?}
  8094. The syntax of the @command{mt} command is:
  8095. @smallexample
  8096. @kbd{mt [-f @var{tapename}] @var{operation} [@var{number}]}
  8097. @end smallexample
  8098. where @var{tapename} is the name of the tape device, @var{number} is
  8099. the number of times an operation is performed (with a default of one),
  8100. and @var{operation} is one of the following:
  8101. @FIXME{is there any use for record operations?}
  8102. @table @option
  8103. @item eof
  8104. @itemx weof
  8105. Writes @var{number} tape marks at the current position on the tape.
  8106. @item fsf
  8107. Moves tape position forward @var{number} files.
  8108. @item bsf
  8109. Moves tape position back @var{number} files.
  8110. @item rewind
  8111. Rewinds the tape. (Ignores @var{number}).
  8112. @item offline
  8113. @itemx rewoff1
  8114. Rewinds the tape and takes the tape device off-line. (Ignores @var{number}).
  8115. @item status
  8116. Prints status information about the tape unit.
  8117. @end table
  8118. @FIXME{Is there a better way to frob the spacing on the list?}
  8119. If you don't specify a @var{tapename}, @command{mt} uses the environment
  8120. variable @env{TAPE}; if @env{TAPE} is not set, @command{mt} will use
  8121. the default device specified in your @file{sys/mtio.h} file
  8122. (@code{DEFTAPE} variable). If this is not defined, the program will
  8123. display a descriptive error message and exit with code 1.
  8124. @command{mt} returns a 0 exit status when the operation(s) were
  8125. successful, 1 if the command was unrecognized, and 2 if an operation
  8126. failed.
  8127. @node Using Multiple Tapes
  8128. @section Using Multiple Tapes
  8129. Often you might want to write a large archive, one larger than will fit
  8130. on the actual tape you are using. In such a case, you can run multiple
  8131. @command{tar} commands, but this can be inconvenient, particularly if you
  8132. are using options like @option{--exclude=@var{pattern}} or dumping entire file systems.
  8133. Therefore, @command{tar} provides a special mode for creating
  8134. multi-volume archives.
  8135. @dfn{Multi-volume} archive is a single @command{tar} archive, stored
  8136. on several media volumes of fixed size. Although in this section we will
  8137. often call @samp{volume} a @dfn{tape}, there is absolutely no
  8138. requirement for multi-volume archives to be stored on tapes. Instead,
  8139. they can use whatever media type the user finds convenient, they can
  8140. even be located on files.
  8141. When creating a multi-volume archive, @GNUTAR{} continues to fill
  8142. current volume until it runs out of space, then it switches to
  8143. next volume (usually the operator is queried to replace the tape on
  8144. this point), and continues working on the new volume. This operation
  8145. continues until all requested files are dumped. If @GNUTAR{} detects
  8146. end of media while dumping a file, such a file is archived in split
  8147. form. Some very big files can even be split across several volumes.
  8148. Each volume is itself a valid @GNUTAR{} archive, so it can be read
  8149. without any special options. Consequently any file member residing
  8150. entirely on one volume can be extracted or otherwise operated upon
  8151. without needing the other volume. Sure enough, to extract a split
  8152. member you would need all volumes its parts reside on.
  8153. Multi-volume archives suffer from several limitations. In particular,
  8154. they cannot be compressed.
  8155. @GNUTAR{} is able to create multi-volume archives of two formats
  8156. (@pxref{Formats}): @samp{GNU} and @samp{POSIX}.
  8157. @menu
  8158. * Multi-Volume Archives:: Archives Longer than One Tape or Disk
  8159. * Tape Files:: Tape Files
  8160. * Tarcat:: Concatenate Volumes into a Single Archive
  8161. @end menu
  8162. @node Multi-Volume Archives
  8163. @subsection Archives Longer than One Tape or Disk
  8164. @cindex Multi-volume archives
  8165. @opindex multi-volume
  8166. To create an archive that is larger than will fit on a single unit of
  8167. the media, use the @option{--multi-volume} (@option{-M}) option in conjunction with
  8168. the @option{--create} option (@pxref{create}). A @dfn{multi-volume}
  8169. archive can be manipulated like any other archive (provided the
  8170. @option{--multi-volume} option is specified), but is stored on more
  8171. than one tape or disk.
  8172. When you specify @option{--multi-volume}, @command{tar} does not report an
  8173. error when it comes to the end of an archive volume (when reading), or
  8174. the end of the media (when writing). Instead, it prompts you to load
  8175. a new storage volume. If the archive is on a magnetic tape, you
  8176. should change tapes when you see the prompt; if the archive is on a
  8177. floppy disk, you should change disks; etc.
  8178. @table @option
  8179. @item --multi-volume
  8180. @itemx -M
  8181. Creates a multi-volume archive, when used in conjunction with
  8182. @option{--create} (@option{-c}). To perform any other operation on a multi-volume
  8183. archive, specify @option{--multi-volume} in conjunction with that
  8184. operation.
  8185. For example:
  8186. @smallexample
  8187. $ @kbd{tar --create --multi-volume --file=/dev/tape @var{files}}
  8188. @end smallexample
  8189. @end table
  8190. The method @command{tar} uses to detect end of tape is not perfect, and
  8191. fails on some operating systems or on some devices. If @command{tar}
  8192. cannot detect the end of the tape itself, you can use
  8193. @option{--tape-length} option to inform it about the capacity of the
  8194. tape:
  8195. @anchor{tape-length}
  8196. @table @option
  8197. @opindex tape-length
  8198. @item --tape-length=@var{size}
  8199. @itemx -L @var{size}
  8200. Set maximum length of a volume. The @var{size} argument should then
  8201. be the usable size of the tape in units of 1024 bytes. This option
  8202. selects @option{--multi-volume} automatically. For example:
  8203. @smallexample
  8204. $ @kbd{tar --create --tape-length=41943040 --file=/dev/tape @var{files}}
  8205. @end smallexample
  8206. @end table
  8207. @anchor{change volume prompt}
  8208. When @GNUTAR{} comes to the end of a storage media, it asks you to
  8209. change the volume. The built-in prompt for POSIX locale
  8210. is@footnote{If you run @GNUTAR{} under a different locale, the
  8211. translation to the locale's language will be used.}:
  8212. @smallexample
  8213. Prepare volume #@var{n} for `@var{archive}' and hit return:
  8214. @end smallexample
  8215. @noindent
  8216. where @var{n} is the ordinal number of the volume to be created and
  8217. @var{archive} is archive file or device name.
  8218. When prompting for a new tape, @command{tar} accepts any of the following
  8219. responses:
  8220. @table @kbd
  8221. @item ?
  8222. Request @command{tar} to explain possible responses
  8223. @item q
  8224. Request @command{tar} to exit immediately.
  8225. @item n @var{file-name}
  8226. Request @command{tar} to write the next volume on the file @var{file-name}.
  8227. @item !
  8228. Request @command{tar} to run a subshell. This option can be disabled
  8229. by giving @option{--restrict} command line option to
  8230. @command{tar}@footnote{@xref{--restrict}, for more information about
  8231. this option}.
  8232. @item y
  8233. Request @command{tar} to begin writing the next volume.
  8234. @end table
  8235. (You should only type @samp{y} after you have changed the tape;
  8236. otherwise @command{tar} will write over the volume it just finished.)
  8237. @cindex Volume number file
  8238. @cindex volno file
  8239. @anchor{volno-file}
  8240. @opindex volno-file
  8241. The volume number used by @command{tar} in its tape-changing prompt
  8242. can be changed; if you give the
  8243. @option{--volno-file=@var{file-of-number}} option, then
  8244. @var{file-of-number} should be an non-existing file to be created, or
  8245. else, a file already containing a decimal number. That number will be
  8246. used as the volume number of the first volume written. When
  8247. @command{tar} is finished, it will rewrite the file with the
  8248. now-current volume number. (This does not change the volume number
  8249. written on a tape label, as per @ref{label}, it @emph{only} affects
  8250. the number used in the prompt.)
  8251. @cindex End-of-archive info script
  8252. @cindex Info script
  8253. @anchor{info-script}
  8254. @opindex info-script
  8255. @opindex new-volume-script
  8256. If you want more elaborate behavior than this, you can write a special
  8257. @dfn{new volume script}, that will be responsible for changing the
  8258. volume, and instruct @command{tar} to use it instead of its normal
  8259. prompting procedure:
  8260. @table @option
  8261. @item --info-script=@var{script-name}
  8262. @itemx --new-volume-script=@var{script-name}
  8263. @itemx -F @var{script-name}
  8264. Specify the full name of the volume script to use. The script can be
  8265. used to eject cassettes, or to broadcast messages such as
  8266. @samp{Someone please come change my tape} when performing unattended
  8267. backups.
  8268. @end table
  8269. The @var{script-name} is executed without any command line
  8270. arguments. It inherits @command{tar}'s shell environment.
  8271. Additional data is passed to it via the following
  8272. environment variables:
  8273. @table @env
  8274. @vrindex TAR_VERSION, info script environment variable
  8275. @item TAR_VERSION
  8276. @GNUTAR{} version number.
  8277. @vrindex TAR_ARCHIVE, info script environment variable
  8278. @item TAR_ARCHIVE
  8279. The name of the archive @command{tar} is processing.
  8280. @vrindex TAR_VOLUME, info script environment variable
  8281. @item TAR_VOLUME
  8282. Ordinal number of the volume @command{tar} is about to start.
  8283. @vrindex TAR_SUBCOMMAND, info script environment variable
  8284. @item TAR_SUBCOMMAND
  8285. Short option describing the operation @command{tar} is executing
  8286. @xref{Operations}, for a complete list of subcommand options.
  8287. @vrindex TAR_FORMAT, info script environment variable
  8288. @item TAR_FORMAT
  8289. Format of the archive being processed. @xref{Formats}, for a complete
  8290. list of archive format names.
  8291. @vrindex TAR_FD, info script environment variable
  8292. @item TAR_FD
  8293. File descriptor which can be used to communicate the new volume
  8294. name to @command{tar}.
  8295. @end table
  8296. The volume script can instruct @command{tar} to use new archive name,
  8297. by writing in to file descriptor @env{$TAR_FD} (see below for an example).
  8298. If the info script fails, @command{tar} exits; otherwise, it begins
  8299. writing the next volume.
  8300. If you want @command{tar} to cycle through a series of files or tape
  8301. drives, there are three approaches to choose from. First of all, you
  8302. can give @command{tar} multiple @option{--file} options. In this case
  8303. the specified files will be used, in sequence, as the successive
  8304. volumes of the archive. Only when the first one in the sequence needs
  8305. to be used again will @command{tar} prompt for a tape change (or run
  8306. the info script). For example, suppose someone has two tape drives on
  8307. a system named @file{/dev/tape0} and @file{/dev/tape1}. For having
  8308. @GNUTAR{} to switch to the second drive when it needs to write the
  8309. second tape, and then back to the first tape, etc., just do either of:
  8310. @smallexample
  8311. $ @kbd{tar --create --multi-volume --file=/dev/tape0 --file=/dev/tape1 @var{files}}
  8312. $ @kbd{tar cMff /dev/tape0 /dev/tape1 @var{files}}
  8313. @end smallexample
  8314. The second method is to use the @samp{n} response to the tape-change
  8315. prompt.
  8316. Finally, the most flexible approach is to use a volume script, that
  8317. writes new archive name to the file descriptor @env{$TAR_FD}. For example, the
  8318. following volume script will create a series of archive files, named
  8319. @file{@var{archive}-@var{vol}}, where @var{archive} is the name of the
  8320. archive being created (as given by @option{--file} option) and
  8321. @var{vol} is the ordinal number of the archive being created:
  8322. @smallexample
  8323. @group
  8324. #! /bin/sh
  8325. echo Preparing volume $TAR_VOLUME of $TAR_ARCHIVE.
  8326. name=`expr $TAR_ARCHIVE : '\(.*\)-.*'`
  8327. case $TAR_SUBCOMMAND in
  8328. -c) ;;
  8329. -d|-x|-t) test -r $@{name:-$TAR_ARCHIVE@}-$TAR_VOLUME || exit 1
  8330. ;;
  8331. *) exit 1
  8332. esac
  8333. echo $@{name:-$TAR_ARCHIVE@}-$TAR_VOLUME >&$TAR_FD
  8334. @end group
  8335. @end smallexample
  8336. The same script cant be used while listing, comparing or extracting
  8337. from the created archive. For example:
  8338. @smallexample
  8339. @group
  8340. # @r{Create a multi-volume archive:}
  8341. $ @kbd{tar -c -L1024 -f archive.tar -F new-volume .}
  8342. # @r{Extract from the created archive:}
  8343. $ @kbd{tar -x -f archive.tar -F new-volume .}
  8344. @end group
  8345. @end smallexample
  8346. @noindent
  8347. Notice, that the first command had to use @option{-L} option, since
  8348. otherwise @GNUTAR{} will end up writing everything to file
  8349. @file{archive.tar}.
  8350. You can read each individual volume of a multi-volume archive as if it
  8351. were an archive by itself. For example, to list the contents of one
  8352. volume, use @option{--list}, without @option{--multi-volume} specified.
  8353. To extract an archive member from one volume (assuming it is described
  8354. that volume), use @option{--extract}, again without
  8355. @option{--multi-volume}.
  8356. If an archive member is split across volumes (i.e., its entry begins on
  8357. one volume of the media and ends on another), you need to specify
  8358. @option{--multi-volume} to extract it successfully. In this case, you
  8359. should load the volume where the archive member starts, and use
  8360. @samp{tar --extract --multi-volume}---@command{tar} will prompt for later
  8361. volumes as it needs them. @xref{extracting archives}, for more
  8362. information about extracting archives.
  8363. Multi-volume archives can be modified like any other archive. To add
  8364. files to a multi-volume archive, you need to only mount the last
  8365. volume of the archive media (and new volumes, if needed). For all
  8366. other operations, you need to use the entire archive.
  8367. If a multi-volume archive was labeled using
  8368. @option{--label=@var{archive-label}} (@pxref{label}) when it was
  8369. created, @command{tar} will not automatically label volumes which are
  8370. added later. To label subsequent volumes, specify
  8371. @option{--label=@var{archive-label}} again in conjunction with the
  8372. @option{--append}, @option{--update} or @option{--concatenate} operation.
  8373. Notice that multi-volume support is a GNU extension and the archives
  8374. created in this mode should be read only using @GNUTAR{}. If you
  8375. absolutely have to process such archives using a third-party @command{tar}
  8376. implementation, read @ref{Split Recovery}.
  8377. @node Tape Files
  8378. @subsection Tape Files
  8379. @UNREVISED
  8380. To give the archive a name which will be recorded in it, use the
  8381. @option{--label=@var{volume-label}} (@option{-V @var{volume-label}})
  8382. option. This will write a special block identifying
  8383. @var{volume-label} as the name of the archive to the front of the
  8384. archive which will be displayed when the archive is listed with
  8385. @option{--list}. If you are creating a multi-volume archive with
  8386. @option{--multi-volume} (@pxref{Using Multiple Tapes}), then the
  8387. volume label will have @samp{Volume @var{nnn}} appended to the name
  8388. you give, where @var{nnn} is the number of the volume of the archive.
  8389. (If you use the @option{--label=@var{volume-label}}) option when
  8390. reading an archive, it checks to make sure the label on the tape
  8391. matches the one you give. @xref{label}.
  8392. When @command{tar} writes an archive to tape, it creates a single
  8393. tape file. If multiple archives are written to the same tape, one
  8394. after the other, they each get written as separate tape files. When
  8395. extracting, it is necessary to position the tape at the right place
  8396. before running @command{tar}. To do this, use the @command{mt} command.
  8397. For more information on the @command{mt} command and on the organization
  8398. of tapes into a sequence of tape files, see @ref{mt}.
  8399. People seem to often do:
  8400. @smallexample
  8401. @kbd{--label="@var{some-prefix} `date +@var{some-format}`"}
  8402. @end smallexample
  8403. or such, for pushing a common date in all volumes or an archive set.
  8404. @node Tarcat
  8405. @subsection Concatenate Volumes into a Single Archive
  8406. @pindex tarcat
  8407. Sometimes it is necessary to convert existing @GNUTAR{} multi-volume
  8408. archive to a single @command{tar} archive. Simply concatenating all
  8409. volumes into one will not work, since each volume carries an additional
  8410. information at the beginning. @GNUTAR{} is shipped with the shell
  8411. script @command{tarcat} designed for this purpose.
  8412. The script takes a list of files comprising a multi-volume archive
  8413. and creates the resulting archive at the standard output. For example:
  8414. @smallexample
  8415. @kbd{tarcat vol.1 vol.2 vol.3 | tar tf -}
  8416. @end smallexample
  8417. The script implements a simple heuristics to determine the format of
  8418. the first volume file and to decide how to process the rest of the
  8419. files. However, it makes no attempt to verify whether the files are
  8420. given in order or even if they are valid @command{tar} archives.
  8421. It uses @command{dd} and does not filter its standard error, so you
  8422. will usually see lots of spurious messages.
  8423. @FIXME{The script is not installed. Should we install it?}
  8424. @node label
  8425. @section Including a Label in the Archive
  8426. @cindex Labeling an archive
  8427. @cindex Labels on the archive media
  8428. @cindex Labeling multi-volume archives
  8429. @UNREVISED
  8430. @opindex label
  8431. To avoid problems caused by misplaced paper labels on the archive
  8432. media, you can include a @dfn{label} entry---an archive member which
  8433. contains the name of the archive---in the archive itself. Use the
  8434. @option{--label=@var{archive-label}} (@option{-V @var{archive-label}})
  8435. option in conjunction with the @option{--create} operation to include
  8436. a label entry in the archive as it is being created.
  8437. @table @option
  8438. @item --label=@var{archive-label}
  8439. @itemx -V @var{archive-label}
  8440. Includes an @dfn{archive-label} at the beginning of the archive when
  8441. the archive is being created, when used in conjunction with the
  8442. @option{--create} operation. Checks to make sure the archive label
  8443. matches the one specified (when used in conjunction with any other
  8444. operation.
  8445. @end table
  8446. If you create an archive using both
  8447. @option{--label=@var{archive-label}} (@option{-V @var{archive-label}})
  8448. and @option{--multi-volume} (@option{-M}), each volume of the archive
  8449. will have an archive label of the form @samp{@var{archive-label}
  8450. Volume @var{n}}, where @var{n} is 1 for the first volume, 2 for the
  8451. next, and so on. @xref{Using Multiple Tapes}, for information on
  8452. creating multiple volume archives.
  8453. @cindex Volume label, listing
  8454. @cindex Listing volume label
  8455. The volume label will be displayed by @option{--list} along with
  8456. the file contents. If verbose display is requested, it will also be
  8457. explicitly marked as in the example below:
  8458. @smallexample
  8459. @group
  8460. $ @kbd{tar --verbose --list --file=iamanarchive}
  8461. V--------- 0 0 0 1992-03-07 12:01 iamalabel--Volume Header--
  8462. -rw-r--r-- ringo user 40 1990-05-21 13:30 iamafilename
  8463. @end group
  8464. @end smallexample
  8465. @opindex test-label
  8466. @anchor{--test-label option}
  8467. However, @option{--list} option will cause listing entire
  8468. contents of the archive, which may be undesirable (for example, if the
  8469. archive is stored on a tape). You can request checking only the volume
  8470. by specifying @option{--test-label} option. This option reads only the
  8471. first block of an archive, so it can be used with slow storage
  8472. devices. For example:
  8473. @smallexample
  8474. @group
  8475. $ @kbd{tar --test-label --file=iamanarchive}
  8476. iamalabel
  8477. @end group
  8478. @end smallexample
  8479. If @option{--test-label} is used with a single command line
  8480. argument, @command{tar} compares the volume label with the
  8481. argument. It exits with code 0 if the two strings match, and with code
  8482. 2 otherwise. In this case no output is displayed. For example:
  8483. @smallexample
  8484. @group
  8485. $ @kbd{tar --test-label --file=iamanarchive 'iamalable'}
  8486. @result{} 0
  8487. $ @kbd{tar --test-label --file=iamanarchive 'iamalable' alabel}
  8488. @result{} 1
  8489. @end group
  8490. @end smallexample
  8491. If you request any operation, other than @option{--create}, along
  8492. with using @option{--label} option, @command{tar} will first check if
  8493. the archive label matches the one specified and will refuse to proceed
  8494. if it does not. Use this as a safety precaution to avoid accidentally
  8495. overwriting existing archives. For example, if you wish to add files
  8496. to @file{archive}, presumably labeled with string @samp{My volume},
  8497. you will get:
  8498. @smallexample
  8499. @group
  8500. $ @kbd{tar -rf archive --label 'My volume' .}
  8501. tar: Archive not labeled to match `My volume'
  8502. @end group
  8503. @end smallexample
  8504. @noindent
  8505. in case its label does not match. This will work even if
  8506. @file{archive} is not labeled at all.
  8507. Similarly, @command{tar} will refuse to list or extract the
  8508. archive if its label doesn't match the @var{archive-label}
  8509. specified. In those cases, @var{archive-label} argument is interpreted
  8510. as a globbing-style pattern which must match the actual magnetic
  8511. volume label. @xref{exclude}, for a precise description of how match
  8512. is attempted@footnote{Previous versions of @command{tar} used full
  8513. regular expression matching, or before that, only exact string
  8514. matching, instead of wildcard matchers. We decided for the sake of
  8515. simplicity to use a uniform matching device through
  8516. @command{tar}.}. If the switch @option{--multi-volume} (@option{-M}) is being used,
  8517. the volume label matcher will also suffix @var{archive-label} by
  8518. @w{@samp{ Volume [1-9]*}} if the initial match fails, before giving
  8519. up. Since the volume numbering is automatically added in labels at
  8520. creation time, it sounded logical to equally help the user taking care
  8521. of it when the archive is being read.
  8522. The @option{--label} was once called @option{--volume}, but is not
  8523. available under that name anymore.
  8524. You can also use @option{--label} to get a common information on
  8525. all tapes of a series. For having this information different in each
  8526. series created through a single script used on a regular basis, just
  8527. manage to get some date string as part of the label. For example:
  8528. @smallexample
  8529. @group
  8530. $ @kbd{tar cfMV /dev/tape "Daily backup for `date +%Y-%m-%d`"}
  8531. $ @kbd{tar --create --file=/dev/tape --multi-volume \
  8532. --volume="Daily backup for `date +%Y-%m-%d`"}
  8533. @end group
  8534. @end smallexample
  8535. Also note that each label has its own date and time, which corresponds
  8536. to when @GNUTAR{} initially attempted to write it,
  8537. often soon after the operator launches @command{tar} or types the
  8538. carriage return telling that the next tape is ready. Comparing date
  8539. labels does give an idea of tape throughput only if the delays for
  8540. rewinding tapes and the operator switching them were negligible, which
  8541. is usually not the case.
  8542. @node verify
  8543. @section Verifying Data as It is Stored
  8544. @cindex Verifying a write operation
  8545. @cindex Double-checking a write operation
  8546. @table @option
  8547. @item -W
  8548. @itemx --verify
  8549. @opindex verify, short description
  8550. Attempt to verify the archive after writing.
  8551. @end table
  8552. This option causes @command{tar} to verify the archive after writing it.
  8553. Each volume is checked after it is written, and any discrepancies
  8554. are recorded on the standard error output.
  8555. Verification requires that the archive be on a back-space-able medium.
  8556. This means pipes, some cartridge tape drives, and some other devices
  8557. cannot be verified.
  8558. You can insure the accuracy of an archive by comparing files in the
  8559. system with archive members. @command{tar} can compare an archive to the
  8560. file system as the archive is being written, to verify a write
  8561. operation, or can compare a previously written archive, to insure that
  8562. it is up to date.
  8563. @xopindex{verify, using with @option{--create}}
  8564. @xopindex{create, using with @option{--verify}}
  8565. To check for discrepancies in an archive immediately after it is
  8566. written, use the @option{--verify} (@option{-W}) option in conjunction with
  8567. the @option{--create} operation. When this option is
  8568. specified, @command{tar} checks archive members against their counterparts
  8569. in the file system, and reports discrepancies on the standard error.
  8570. To verify an archive, you must be able to read it from before the end
  8571. of the last written entry. This option is useful for detecting data
  8572. errors on some tapes. Archives written to pipes, some cartridge tape
  8573. drives, and some other devices cannot be verified.
  8574. One can explicitly compare an already made archive with the file
  8575. system by using the @option{--compare} (@option{--diff}, @option{-d})
  8576. option, instead of using the more automatic @option{--verify} option.
  8577. @xref{compare}.
  8578. Note that these two options have a slightly different intent. The
  8579. @option{--compare} option checks how identical are the logical contents of some
  8580. archive with what is on your disks, while the @option{--verify} option is
  8581. really for checking if the physical contents agree and if the recording
  8582. media itself is of dependable quality. So, for the @option{--verify}
  8583. operation, @command{tar} tries to defeat all in-memory cache pertaining to
  8584. the archive, while it lets the speed optimization undisturbed for the
  8585. @option{--compare} option. If you nevertheless use @option{--compare} for
  8586. media verification, you may have to defeat the in-memory cache yourself,
  8587. maybe by opening and reclosing the door latch of your recording unit,
  8588. forcing some doubt in your operating system about the fact this is really
  8589. the same volume as the one just written or read.
  8590. The @option{--verify} option would not be necessary if drivers were indeed
  8591. able to detect dependably all write failures. This sometimes require many
  8592. magnetic heads, some able to read after the writes occurred. One would
  8593. not say that drivers unable to detect all cases are necessarily flawed,
  8594. as long as programming is concerned.
  8595. The @option{--verify} (@option{-W}) option will not work in
  8596. conjunction with the @option{--multi-volume} (@option{-M}) option or
  8597. the @option{--append} (@option{-r}), @option{--update} (@option{-u})
  8598. and @option{--delete} operations. @xref{Operations}, for more
  8599. information on these operations.
  8600. Also, since @command{tar} normally strips leading @samp{/} from file
  8601. names (@pxref{absolute}), a command like @samp{tar --verify -cf
  8602. /tmp/foo.tar /etc} will work as desired only if the working directory is
  8603. @file{/}, as @command{tar} uses the archive's relative member names
  8604. (e.g., @file{etc/motd}) when verifying the archive.
  8605. @node Write Protection
  8606. @section Write Protection
  8607. Almost all tapes and diskettes, and in a few rare cases, even disks can
  8608. be @dfn{write protected}, to protect data on them from being changed.
  8609. Once an archive is written, you should write protect the media to prevent
  8610. the archive from being accidentally overwritten or deleted. (This will
  8611. protect the archive from being changed with a tape or floppy drive---it
  8612. will not protect it from magnet fields or other physical hazards).
  8613. The write protection device itself is usually an integral part of the
  8614. physical media, and can be a two position (write enabled/write
  8615. disabled) switch, a notch which can be popped out or covered, a ring
  8616. which can be removed from the center of a tape reel, or some other
  8617. changeable feature.
  8618. @node Changes
  8619. @appendix Changes
  8620. This appendix lists some important user-visible changes between
  8621. version @GNUTAR{} @value{VERSION} and previous versions. An up-to-date
  8622. version of this document is available at
  8623. @uref{http://www.gnu.org/@/software/@/tar/manual/changes.html,the
  8624. @GNUTAR{} documentation page}.
  8625. @table @asis
  8626. @item Use of globbing patterns when listing and extracting.
  8627. Previous versions of GNU tar assumed shell-style globbing when
  8628. extracting from or listing an archive. For example:
  8629. @smallexample
  8630. $ @kbd{tar xf foo.tar '*.c'}
  8631. @end smallexample
  8632. would extract all files whose names end in @samp{.c}. This behavior
  8633. was not documented and was incompatible with traditional tar
  8634. implementations. Therefore, starting from version 1.15.91, GNU tar
  8635. no longer uses globbing by default. For example, the above invocation
  8636. is now interpreted as a request to extract from the archive the file
  8637. named @file{*.c}.
  8638. To facilitate transition to the new behavior for those users who got
  8639. used to the previous incorrect one, @command{tar} will print a warning
  8640. if it finds out that a requested member was not found in the archive
  8641. and its name looks like a globbing pattern. For example:
  8642. @smallexample
  8643. $ @kbd{tar xf foo.tar '*.c'}
  8644. tar: Pattern matching characters used in file names. Please,
  8645. tar: use --wildcards to enable pattern matching, or --no-wildcards to
  8646. tar: suppress this warning.
  8647. tar: *.c: Not found in archive
  8648. tar: Error exit delayed from previous errors
  8649. @end smallexample
  8650. To treat member names as globbing patterns, use --wildcards option.
  8651. If you want to tar to mimic the behavior of versions prior to 1.15.91,
  8652. add this option to your @env{TAR_OPTIONS} variable.
  8653. @xref{wildcards}, for the detailed discussion of the use of globbing
  8654. patterns by @GNUTAR{}.
  8655. @item Use of short option @option{-o}.
  8656. Earlier versions of @GNUTAR{} understood @option{-o} command line
  8657. option as a synonym for @option{--old-archive}.
  8658. @GNUTAR{} starting from version 1.13.90 understands this option as
  8659. a synonym for @option{--no-same-owner}. This is compatible with
  8660. UNIX98 @command{tar} implementations.
  8661. However, to facilitate transition, @option{-o} option retains its
  8662. old semantics when it is used with one of archive-creation commands.
  8663. Users are encouraged to use @option{--format=oldgnu} instead.
  8664. It is especially important, since versions of @acronym{GNU} Automake
  8665. up to and including 1.8.4 invoke tar with this option to produce
  8666. distribution tarballs. @xref{Formats,v7}, for the detailed discussion
  8667. of this issue and its implications.
  8668. @FIXME{Change the first argument to tar-formats when the new Automake is
  8669. out. The proposition to add @anchor{} to the appropriate place of its
  8670. docs was accepted by Automake people --Sergey 2006-05-25}.
  8671. @xref{Options, tar-v7, Changing Automake's Behavior,
  8672. automake, GNU Automake}, for a description on how to use various
  8673. archive formats with @command{automake}.
  8674. Future versions of @GNUTAR{} will understand @option{-o} only as a
  8675. synonym for @option{--no-same-owner}.
  8676. @item Use of short option @option{-l}
  8677. Earlier versions of @GNUTAR{} understood @option{-l} option as a
  8678. synonym for @option{--one-file-system}. Since such usage contradicted
  8679. to UNIX98 specification and harmed compatibility with other
  8680. implementation, it was declared deprecated in version 1.14. However,
  8681. to facilitate transition to its new semantics, it was supported by
  8682. versions 1.15 and 1.15.90. The present use of @option{-l} as a short
  8683. variant of @option{--check-links} was introduced in version 1.15.91.
  8684. @item Use of options @option{--portability} and @option{--old-archive}
  8685. These options are deprecated. Please use @option{--format=v7} instead.
  8686. @item Use of option @option{--posix}
  8687. This option is deprecated. Please use @option{--format=posix} instead.
  8688. @end table
  8689. @node Configuring Help Summary
  8690. @appendix Configuring Help Summary
  8691. Running @kbd{tar --help} displays the short @command{tar} option
  8692. summary (@pxref{help}). This summary is organized by @dfn{groups} of
  8693. semantically close options. The options within each group are printed
  8694. in the following order: a short option, eventually followed by a list
  8695. of corresponding long option names, followed by a short description of
  8696. the option. For example, here is an excerpt from the actual @kbd{tar
  8697. --help} output:
  8698. @verbatim
  8699. Main operation mode:
  8700. -A, --catenate, --concatenate append tar files to an archive
  8701. -c, --create create a new archive
  8702. -d, --diff, --compare find differences between archive and
  8703. file system
  8704. --delete delete from the archive
  8705. @end verbatim
  8706. @vrindex ARGP_HELP_FMT, environment variable
  8707. The exact visual representation of the help output is configurable via
  8708. @env{ARGP_HELP_FMT} environment variable. The value of this variable
  8709. is a comma-separated list of @dfn{format variable} assignments. There
  8710. are two kinds of format variables. An @dfn{offset variable} keeps the
  8711. offset of some part of help output text from the leftmost column on
  8712. the screen. A @dfn{boolean} variable is a flag that toggles some
  8713. output feature on or off. Depending on the type of the corresponding
  8714. variable, there are two kinds of assignments:
  8715. @table @asis
  8716. @item Offset assignment
  8717. The assignment to an offset variable has the following syntax:
  8718. @smallexample
  8719. @var{variable}=@var{value}
  8720. @end smallexample
  8721. @noindent
  8722. where @var{variable} is the variable name, and @var{value} is a
  8723. numeric value to be assigned to the variable.
  8724. @item Boolean assignment
  8725. To assign @code{true} value to a variable, simply put this variable name. To
  8726. assign @code{false} value, prefix the variable name with @samp{no-}. For
  8727. example:
  8728. @smallexample
  8729. @group
  8730. # Assign @code{true} value:
  8731. dup-args
  8732. # Assign @code{false} value:
  8733. no-dup-args
  8734. @end group
  8735. @end smallexample
  8736. @end table
  8737. Following variables are declared:
  8738. @deftypevr {Help Output} boolean dup-args
  8739. If true, arguments for an option are shown with both short and long
  8740. options, even when a given option has both forms, for example:
  8741. @smallexample
  8742. -f ARCHIVE, --file=ARCHIVE use archive file or device ARCHIVE
  8743. @end smallexample
  8744. If false, then if an option has both short and long forms, the
  8745. argument is only shown with the long one, for example:
  8746. @smallexample
  8747. -f, --file=ARCHIVE use archive file or device ARCHIVE
  8748. @end smallexample
  8749. @noindent
  8750. and a message indicating that the argument is applicable to both
  8751. forms is printed below the options. This message can be disabled
  8752. using @code{dup-args-note} (see below).
  8753. The default is false.
  8754. @end deftypevr
  8755. @deftypevr {Help Output} boolean dup-args-note
  8756. If this variable is true, which is the default, the following notice
  8757. is displayed at the end of the help output:
  8758. @quotation
  8759. Mandatory or optional arguments to long options are also mandatory or
  8760. optional for any corresponding short options.
  8761. @end quotation
  8762. Setting @code{no-dup-args-note} inhibits this message. Normally, only one of
  8763. variables @code{dup-args} or @code{dup-args-note} should be set.
  8764. @end deftypevr
  8765. @deftypevr {Help Output} offset short-opt-col
  8766. Column in which short options start. Default is 2.
  8767. @smallexample
  8768. @group
  8769. $ @kbd{tar --help|grep ARCHIVE}
  8770. -f, --file=ARCHIVE use archive file or device ARCHIVE
  8771. $ @kbd{ARGP_HELP_FMT=short-opt-col=6 tar --help|grep ARCHIVE}
  8772. -f, --file=ARCHIVE use archive file or device ARCHIVE
  8773. @end group
  8774. @end smallexample
  8775. @end deftypevr
  8776. @deftypevr {Help Output} offset long-opt-col
  8777. Column in which long options start. Default is 6. For example:
  8778. @smallexample
  8779. @group
  8780. $ @kbd{tar --help|grep ARCHIVE}
  8781. -f, --file=ARCHIVE use archive file or device ARCHIVE
  8782. $ @kbd{ARGP_HELP_FMT=long-opt-col=16 tar --help|grep ARCHIVE}
  8783. -f, --file=ARCHIVE use archive file or device ARCHIVE
  8784. @end group
  8785. @end smallexample
  8786. @end deftypevr
  8787. @deftypevr {Help Output} offset doc-opt-col
  8788. Column in which @dfn{doc options} start. A doc option isn't actually
  8789. an option, but rather an arbitrary piece of documentation that is
  8790. displayed in much the same manner as the options. For example, in
  8791. the description of @option{--format} option:
  8792. @smallexample
  8793. @group
  8794. -H, --format=FORMAT create archive of the given format.
  8795. FORMAT is one of the following:
  8796. gnu GNU tar 1.13.x format
  8797. oldgnu GNU format as per tar <= 1.12
  8798. pax POSIX 1003.1-2001 (pax) format
  8799. posix same as pax
  8800. ustar POSIX 1003.1-1988 (ustar) format
  8801. v7 old V7 tar format
  8802. @end group
  8803. @end smallexample
  8804. @noindent
  8805. the format names are doc options. Thus, if you set
  8806. @kbd{ARGP_HELP_FMT=doc-opt-col=6} the above part of the help output
  8807. will look as follows:
  8808. @smallexample
  8809. @group
  8810. -H, --format=FORMAT create archive of the given format.
  8811. FORMAT is one of the following:
  8812. gnu GNU tar 1.13.x format
  8813. oldgnu GNU format as per tar <= 1.12
  8814. pax POSIX 1003.1-2001 (pax) format
  8815. posix same as pax
  8816. ustar POSIX 1003.1-1988 (ustar) format
  8817. v7 old V7 tar format
  8818. @end group
  8819. @end smallexample
  8820. @end deftypevr
  8821. @deftypevr {Help Output} offset opt-doc-col
  8822. Column in which option description starts. Default is 29.
  8823. @smallexample
  8824. @group
  8825. $ @kbd{tar --help|grep ARCHIVE}
  8826. -f, --file=ARCHIVE use archive file or device ARCHIVE
  8827. $ @kbd{ARGP_HELP_FMT=opt-doc-col=19 tar --help|grep ARCHIVE}
  8828. -f, --file=ARCHIVE use archive file or device ARCHIVE
  8829. $ @kbd{ARGP_HELP_FMT=opt-doc-col=9 tar --help|grep ARCHIVE}
  8830. -f, --file=ARCHIVE
  8831. use archive file or device ARCHIVE
  8832. @end group
  8833. @end smallexample
  8834. @noindent
  8835. Notice, that the description starts on a separate line if
  8836. @code{opt-doc-col} value is too small.
  8837. @end deftypevr
  8838. @deftypevr {Help Output} offset header-col
  8839. Column in which @dfn{group headers} are printed. A group header is a
  8840. descriptive text preceding an option group. For example, in the
  8841. following text:
  8842. @verbatim
  8843. Main operation mode:
  8844. -A, --catenate, --concatenate append tar files to
  8845. an archive
  8846. -c, --create create a new archive
  8847. @end verbatim
  8848. @noindent
  8849. @samp{Main operation mode:} is the group header.
  8850. The default value is 1.
  8851. @end deftypevr
  8852. @deftypevr {Help Output} offset usage-indent
  8853. Indentation of wrapped usage lines. Affects @option{--usage}
  8854. output. Default is 12.
  8855. @end deftypevr
  8856. @deftypevr {Help Output} offset rmargin
  8857. Right margin of the text output. Used for wrapping.
  8858. @end deftypevr
  8859. @node Fixing Snapshot Files
  8860. @appendix Fixing Snapshot Files
  8861. @include tar-snapshot-edit.texi
  8862. @node Tar Internals
  8863. @appendix Tar Internals
  8864. @include intern.texi
  8865. @node Genfile
  8866. @appendix Genfile
  8867. @include genfile.texi
  8868. @node Free Software Needs Free Documentation
  8869. @appendix Free Software Needs Free Documentation
  8870. @include freemanuals.texi
  8871. @node Copying This Manual
  8872. @appendix Copying This Manual
  8873. @menu
  8874. * GNU Free Documentation License:: License for copying this manual
  8875. @end menu
  8876. @include fdl.texi
  8877. @node Index of Command Line Options
  8878. @appendix Index of Command Line Options
  8879. This appendix contains an index of all @GNUTAR{} long command line
  8880. options. The options are listed without the preceding double-dash.
  8881. For a cross-reference of short command line options, @ref{Short Option Summary}.
  8882. @printindex op
  8883. @node Index
  8884. @appendix Index
  8885. @printindex cp
  8886. @summarycontents
  8887. @contents
  8888. @bye
  8889. @c Local variables:
  8890. @c texinfo-column-for-description: 32
  8891. @c End: