Help with Tar command needed


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Help with Tar command needed
# 1  
Old 05-12-2015
Help with Tar command needed

Lets say I have 100 files. in those files I need to search specific word and I want to tar all those files at once. how can I do that?
Code:
tar -cvf test.tar |grep house *.*

Will it work?



Moderator's Comments:
Mod Comment
Please wrap all code, files, input & output/errors in CODE tags.
It makes them easier to read and preserves multiple spaces, which is very important for fixed width data and code indenting.

Last edited by rbatte1; 05-12-2015 at 08:37 AM.. Reason: Added CODE tags, corrected spelling, punctuation and capital letters
# 2  
Old 05-12-2015
No, you need a list of files with the word house in them rather than the "normal" grep output, also you need to provide the filenames as arguments to the tar command...

Code:
tar -cvf test.tar $(grep -l house *.*)

This User Gave Thanks to Skrynesaver For This Post:
# 3  
Old 05-28-2015
many thanks to all
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

UNIX command to check if file name ends with .tar OR if the file is a tar file

Hello Team, Would you please help me with a UNIX command that would check if file is a tar file. if we dont have that , can you help me with UNIX command that would check if file ends with .tar Thanks in advance. (10 Replies)
Discussion started by: sanjaydubey2006
10 Replies

2. UNIX for Dummies Questions & Answers

Tar Command Help

Is it possible to untar a file so it's size reduces while it uncompresses its contents. I have limited space on my mount point and was wondering if we can untar as a stream in other words the size of tarball reduces as it uncompresses the contents. Thanks (5 Replies)
Discussion started by: sumang24
5 Replies

3. Shell Programming and Scripting

Single command - unzip files from a tar command

I have a tar file that contains multiple .Z files. Hence I need to issue a tar command followed by a gzip command to fully extract the files. How do I do it in a single command? What I'm doing now is tar xvf a.tar (this will output 1.Z and 2.Z) gzip -d *.Z (to extract 1.Z and 2.Z) (9 Replies)
Discussion started by: ericlim
9 Replies

4. Shell Programming and Scripting

tar command to explore multiple layers of tar and tar.gz files

Hi all, I have a tar file and inside that tar file is a folder with additional tar.gz files. What I want to do is look inside the first tar file and then find the second tar file I'm looking for, look inside that tar.gz file to find a certain directory. I'm encountering issues by trying to... (1 Reply)
Discussion started by: bashnewbee
1 Replies

5. 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

6. UNIX for Dummies Questions & Answers

tar -cvf test.tar `find . -mtime -1 -type f` only tar 1 file

Hi all, 4 files are returned when i issue 'find . -mtime -1 -type f -ls'. ./ora_475244.aud ./ora_671958.aud ./ora_934052.aud ./ora_934050.aud However, when I issued the below command: tar -cvf test.tar `find . -mtime -1 -type f`, the tar file only contains the 1st file -... (2 Replies)
Discussion started by: ahSher
2 Replies

7. Shell Programming and Scripting

Tar command

I want to tar multiple folder from a environment but exclude 2 folders among them. How can I do that. Is there any exclude option in tar command. Please co-operate me. Thanking you, Chandrakant. (8 Replies)
Discussion started by: get_chandrakant
8 Replies

8. UNIX for Dummies Questions & Answers

Need help with tar command

Can anyone help me to staff three files with tar command and then unstaff them Thx in advance for any help. (2 Replies)
Discussion started by: Geldy
2 Replies

9. Solaris

tar - help needed

I need to retrieve one file from tape which appears to be dumped to using tar. I have tried the following command - but no luck. Any ideas? I dont want to to restore the complete backup - just one file. tar -xf /dev/rmt/0cn /var/opt/tmp/AA/dump/TEST.DUMP_20051003 Backup script looks... (6 Replies)
Discussion started by: frustrated1
6 Replies

10. UNIX for Advanced & Expert Users

Tar Command

Suppose that you have to restore a file from a TAR and put it in a different directory. To be more clear, suppose that you have a TAR file (backup of 3 files) : tar -tvf TARfile /data1/file1 /data2/data/file2 /data3/file3 You need to restore file2 to /tmp/file2.tmp ? Is it possible ? if... (1 Reply)
Discussion started by: sof
1 Replies
Login or Register to Ask a Question