LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-02-2009, 02:36 PM   #1
BassKozz
Member
 
Registered: Dec 2008
Distribution: Ubuntu 8.10
Posts: 35

Rep: Reputation: 15
tar doesn't compress .hidden files in the same directory it is run in?


Example Directory Contains:
.htaccess
.news
info.txt
info.log
Code:
tar -cvpzf test.tgz ./*
./info.log
./info.txt
What gives, why isn't .htaccess or .news being added to the tar?

Furthermore if there is a .htaccess file in a subdirectory it is compressed.

Example Directory Contains:
.htaccess
.news
info.txt
info.log
/subdir/.htaccess/
Code:
tar -cvpzf test.tgz ./*
./info.log
./info.txt
./subdir/
./subdir/.htaccess
Why is this, how do I work-around?
 
Old 06-02-2009, 02:48 PM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Globbing with * does not include hidden files, whereas every file in a directory (hidden ones included) are put into the archive. So you can simply do
Code:
$ tar -cvpzf test.tgz .
However, you can force the shell to include hidden files in globbing, using
Code:
$ shopt -s dotglob
$ tar -cvpzf test.tgz ./*
$ shopt -u dotglob         # to disable the shell option

Last edited by colucix; 06-02-2009 at 04:48 PM.
 
Old 06-02-2009, 04:46 PM   #3
BassKozz
Member
 
Registered: Dec 2008
Distribution: Ubuntu 8.10
Posts: 35

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by colucix View Post
Globbing with * does not include hidden files, whereas every file in a directory (hidden ones included) are put into the archive. So you can simply do
Code:
$ tar -cvpzf test.tgz .
However, you can force the shell to include hidden files in globbing, using
Code:
$ shopt -s dotglob
$ tar -cvpzf test.tgz .
$ shopt -u dotglob         # to disable the shell option
Thanks colucix, using "tar -cvpzf test.tgz ." did the trick :-D
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
tar ONLY hidden files MS3FGX Linux - Software 13 01-13-2014 10:46 AM
Can I back up hidden files using tar? opto Linux - Newbie 6 11-05-2006 09:35 AM
compress a directory using tar muskiediver Linux - General 4 07-18-2006 10:24 AM
home directory files gone, hidden files remain Grasshopper Linux - Security 12 04-10-2005 08:23 PM
tar and hidden files jjthomas Linux - General 4 04-07-2005 08:37 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration