Using tar for current directory, but not subs


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Using tar for current directory, but not subs
# 1  
Old 09-10-2004
Using tar for current directory, but not subs

I know that I can type

tar -cvf myfile.tar *

to tar the current directory and all it's sub directories, but how do I tar ONLY the current directory and skip all the subdirectories?
# 2  
Old 09-10-2004
You can try this link

Cheers!!
# 3  
Old 09-13-2004
You could do something like
Code:
ls -l | grep '^[^d]' | awk '{print $9}' | xargs tar cvf foo.tar

to exclude subdirectories too (providing you execute this command from within the directory you want tar'd).

Cheers
ZB
# 4  
Old 09-13-2004
Thanks
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Making Tar of directory and tar file is going to be placed

Quick question, is it possible to make a Tar of completely directory and placing the tar file in it (will this cause even the tar file to tarred ?) sample: /opt/freeware/bin/tar -cvf - /oracle | gzip > /oracle/backup.tgz will the tar file backup.tgz also include backup.tgz ? i tried... (5 Replies)
Discussion started by: filosophizer
5 Replies

2. UNIX for Dummies Questions & Answers

How to get the current directory Path?

How to get the current directory Path in your prompt? i am getting a $ mark only in my prompt? Please help me with this (3 Replies)
Discussion started by: Abhishek0683
3 Replies

3. Shell Programming and Scripting

[Solved] How to tar data along with current system date and time.?

Hi all, Following is my small script:- #!/bin/ksh for i in `cat /users/jack/mainfile-dr.txt` do sudo cp -r $i /users/jack/DR01/. done cd /users/jack/DR01/ sudo tar cvf system1-DR.tar * scp system1-DR.tar backupserver:/DRFiles/system1 sudo rm -rf system1-DR.tar In this script I... (10 Replies)
Discussion started by: manalisharmabe
10 Replies

4. UNIX for Dummies Questions & Answers

tar file from current folder

Hello guys, I am sure this has been asked before, but honestly, I cant find post talking about it. Here is what I need: - A tar file will be generated manually by user - This tar file is then used within a bash shell script My source folder structure is like this: ... (2 Replies)
Discussion started by: manolain
2 Replies

5. UNIX for Dummies Questions & Answers

List directories, subs and files

Hi, I try to list all files in a folder, including all the subdirs (and their subdirs) and all files contained in each of these folders. I then print it to a simple txt file. I use ls -R -1 >test.txt This sort of does what I need, yet, the result is something like: It reasonably comes... (53 Replies)
Discussion started by: dakke
53 Replies

6. UNIX for Advanced & Expert Users

How to rsync or tar directory trees, with hidden directory, but without files?

I want to backup all the directory tress, including hidden directories, without copying any files. find . -type d gives the perfect list. When I tried tar, it won't work for me because it tars all the files. find . -type d | xargs tar -cvf a.tar So i tried rsync. On my own test box, the... (4 Replies)
Discussion started by: fld2007
4 Replies

7. Shell Programming and Scripting

tar command dont tar to original directory

HI, if I have a tarfile called pmapdata.tar that contains tar -tvf pmapdata.tar -rw-r--r-- 0/0 21 Oct 15 11:00 2009 /var/tmp/pmapdata/pmap4628.txt -rw-r--r-- 0/0 21 Oct 14 20:00 2009 /var/tmp/pmapdata/pmap23752.txt -rw-r--r-- 0/0 1625 Oct 13 20:00 2009... (1 Reply)
Discussion started by: borderblaster
1 Replies

8. Shell Programming and Scripting

tar the entire directory except one directory

Hi All, I need to tar the entire directory except one directory inside that. I have used the below command tar -cvfX test.tar bin/perl bin/ I need to tar all the directories inside the bindirectory except the perl directory Please help me in solving this :b: Regards, Kalai (4 Replies)
Discussion started by: kalpeer
4 Replies

9. Shell Programming and Scripting

Finding files in current directory when 100,000's files in current directory

Hi All I was wondering what is the most efficient way to find files in the current directory(that may contain 100,000's files), that meets a certain specified file type and of a certain age. I have experimented with the find command in unix but it also searches all sub directories. I have... (2 Replies)
Discussion started by: kewong007
2 Replies

10. UNIX for Dummies Questions & Answers

how to remove same file in the dir and subs?

Hi all, Let say I have abc.gif file in the dir: A A/Sub1 A/Sub2 This abc.gif file is located in each of the dir and its sub. I want to be able to remove it at once w/out going into each folder and remove it one at a time. What is the command to do that? Thanks (3 Replies)
Discussion started by: jasonhawaii
3 Replies
Login or Register to Ask a Question