To loop over all files in the current directory, do
You will want to tweak down the diagnostics so it doesn't complain about each and every file it doesn't know how to handle.
You still have $1 in a lot of places where you should now have $I (dollar capital I). Basically anywhere outside the function, you want $I (ih) not $1 (one).
The temporary move of the packed file into the directory where you extract it seems superfluous; just $command ../"$I" instead. If you change that, you will need to make some changes to the code where it moves the file to the store_folder, too.
No, the ... was just to signal that you'd continue as before from that point on.
Just take out the three dots after "do" and fix the one remaining occurrence of $1 (in the case -- you should have case $I in --) and you should be fine. Oh, and you should either not move the file before unzipping it, and use $command "../$I" (there are no spaces between ../ and $I -- it means unzip the file $I in the parent directory), or move the file to the current directory, and omit the ../
You might want to put in some error checking, too: if the directory you want to create already exists, should it just go there anyway, or perhaps add a suffix to the directory name and try again, for example?
Similarly, if you run it on multiple files, store_folder will already exist at least after the first iteration, but it might also exist after a previous run. If nothing else, you probably want to avoid the warnings from attempting to create a directory which already exists. For that particular case, it's probably sufficient to simply check if it exists already, and only if not, try to create it.
Hi,
I have a problem with unzipping some file.xml.bz2 files to file.xml using while loop.
all other processing on files is successfull except bunzip2.
here is my piece of code
while read i
do
bunzip2 $i
done<file.lst;
output
: No such file or directory.le... (14 Replies)
Hello all!
This is my first post and I'm very new to programming. I would like help creating a simple perl or bash script that I will be using in my work as a junior bioinformatician.
Essentially, I would like to take a tab-delimted or .csv text with 3 columns and write them to a "3D" matrix:
... (16 Replies)
Hi I have a code like this:
sub WriteEbcdicHeader
{
my $Htimestamp=localtime();#i need to pack and unpack this
my $eheaderline = $Htimestamp;
#packing has to be done here
#unpacking has to be done after packing
print $EOUTFILE
return $eheaderline;
}
sub WriteEbcdicTrailer
{
... (5 Replies)
Hi there,
I wrote the following code:
if ($SCENE == *.tar) then
echo "tar -xf $SCENE"
tar -xf $SCENE > tar.txt
set dims = `awk '$0' tar.txt`
echo "name of dims is:"
echo "$dims"
endif
My intension is, to write a variable "dims" with the output name of the tar-command. That means,... (6 Replies)
i have about 30 .EAR files, every ear file have 1 .JAR file.
so i need to extract .EAR files then extract .JAR files, and one important thing is that every archive must bee extracted to separate folder.
i try with gzip, but when i extract 30 ear files i cant make separate folders.... (1 Reply)
Hi all,
I want to unpack some files .Files and their sizes are:
1. Linux9i_Disk1.cpio -- 500m
2. Linux9i_Disk2.cpio--- 600m
3.Linux9i_Disk3.cpio---- 250m
I used cpio -idmv Linux9i_Disk1.cpio command to unpack the files. But Its taking more time to unpack the files.What could be the... (2 Replies)
I have a file that contains user id and corresponding password.
Lets say password is "help". The below command will create a hex value for string "help".
perl -e 'print unpack "H*","help"'
So now password is in encoded format.
Then I decoded it in the script where am fetching the... (1 Reply)