Add -r to the xargs. This should prevent xargs from running the tar if there isn't anything on the input.
However, you really need to reconsider using tar with xargs. If the filename arguments are long enough to cause xargs to run a second tar command you'll overwrite the first and it will appear that you only got the last n files in your archive.
Try this in a directory with a few files and see what happens:
The output from the -v will indicate that all files were passed to tar, but the table of contents will show only one file. (-L causes xargs to use at most one input line per invocation simulating what it would do if it needed to invoke multiple instances of tar)
Last edited by agama; 11-15-2011 at 09:20 PM..
Reason: clarity
Hi,
After checking all the UNIX threads, I am able to come up with a solution so far. I am working on a shell script where it moves the files to a certain directory. The conditions to check are
1) Check if the file exists in the current directory.
2) Check if the destination directory... (2 Replies)
I can't get touch to simultaneously create three empty files file1, file2, file3. I tried:$ touch filebut all I got was one file:$ fileWhat did I do wrong? (4 Replies)
I am adding some individual files to a tar archive and would like them to be added to the archive without any directory hierarchy, even though the files themselves exist in levels of hierarchy. Unfortunately, tar seems to always preserve the directory hierarchy when it adds the files.
Here is... (2 Replies)
First and foremost - me != unix bubba.
Here is the situation. We have a box with data AND settings in the same directory path. (Data files aren't in the SAME directories as settings.) I need a script that generates a tarred-up archive of only the INI files with the directory structure. We... (2 Replies)
Plese help I need a urgent requirement.
Ex: test.log
requirement : using shell script I need to archive the log file and nil and the content of (test.log) file to 0 kb
and then in the archive folder log files are name to test.tar
test1.tar
test2.tar
EX:
/home/abc/
test.log ... (1 Reply)
Hello Guys.
Please I would like to create empty files from a list
In file1 will be the followin values, so i will like to create for each name a empty file.
file1
2191off-r0.sps
2192off-r0.sps
2193off-r0.sps
2194off-r0.sps
2195off-r0.sps
So I need to get 5 empty files.
Thanks for... (7 Replies)
Hi,
I have a test.zip archive that contains
test.zip --> (file_1.txt, file_2.txt , file_3.txt)
I need to unzip the file like this,
file_1_timestamp.txt
file_1_timestamp.trg
file_2_timestamp.txt
file_2_timestamp.trg
file_3_timestamp.txt
file_3_timestamp.trg
Could you please let me know... (7 Replies)
I need a debian 8 jessie mipsel for create packages for my vuduo(the system is identical to a Debian 8 mipsel environment).
I have some problems.
I usually use Slackware14.2+crosscompile.
For some packages (tcpdump,rsync) works without problem, for other(extundelete for example) not
So I decide... (1 Reply)