in reply to foreach loop to untar multiple files
Thank you all, I will be doing the relevant reading (on glob) and modifying the script accordingly.
I've already copied and tried this
my $results = "~/results"; # results coming in. for (glob "$results/*.tar.gz") { system "tar -tvf $_"; }
...and it does what I want.
I've tried the following modification in my script though, and something funny happens again.
foreach (@tar) { `tar -tvf $results\/$_`; }
This gives me the following error:
tar: /home/user/results//home/user/results/results_back.tar.gz: Cannot open: No such file or directory
So the path to the tar.gz file is messed up obviously. But then my hopes build up because I see that it finds the tar.gz file and that's when I stupidly try to be "clever" by removing $results completely from the command and only keeping $_. In that case I'm just getting nothing, it fails quietly. Why is that?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: foreach loop to untar multiple files
by RichardK (Parson) on Nov 13, 2015 at 17:40 UTC | |
Re^2: foreach loop to untar multiple files
by stevieb (Canon) on Nov 13, 2015 at 17:16 UTC | |
by afoken (Chancellor) on Nov 13, 2015 at 17:59 UTC | |
by fasoli (Beadle) on Nov 13, 2015 at 17:22 UTC | |
by stevieb (Canon) on Nov 13, 2015 at 17:38 UTC |