Re: simple sh scripting. How to put a result of a command to avariable?
Michael Conlen wrote: Constantine wrote: I am writing a script, which involves unzipping some files. I would have to unzip 4 different zip-files from some directory, and I would need to unzip them to the directory, which would have the same name in it as the original zip-file, i.e. I would like to run something like "ls *.zip", have each file name recorded in some variable, and do a loop like "unzip $filename[$i] -d $filename[$i].unzipped/". Can someone help me with the code? How can I put the results of a command to a variable? If I understand you properly I think the following would do what you want #!/bin/sh for i in `ls *.zip` do unzip ${i} -d ${i}.unzipped done Thank you very much indeed! Seems just what I wanted. But can I save the archive names in an array for further manipulation? Also, how can I type that apostrophe ` from my keyboard? Cheers, Constantine. ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: simple sh scripting. How to put a result of a command to avariable?
Constantine wrote: Hello! I am writing a script, which involves unzipping some files. I would have to unzip 4 different zip-files from some directory, and I would need to unzip them to the directory, which would have the same name in it as the original zip-file, i.e. I would like to run something like "ls *.zip", have each file name recorded in some variable, and do a loop like "unzip $filename[$i] -d $filename[$i].unzipped/". Can someone help me with the code? How can I put the results of a command to a variable? If I understand you properly I think the following would do what you want #!/bin/sh for i in `ls *.zip` do unzip ${i} -d ${i}.unzipped done ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: simple sh scripting. How to put a result of a command to avariable?
On Mon, Aug 11, 2003 at 06:17:25PM -0400, Michael Conlen wrote: > #!/bin/sh > for i in `ls *.zip` Useless use of backticks --- what about for i in *.zip ? > do >unzip ${i} -d ${i}.unzipped > done -- What do you care what other people think? pgp0.pgp Description: PGP signature
Re: simple sh scripting. How to put a result of a command to avariable?
On Mon, Aug 11, 2003 at 06:35:17PM -0400 or thereabouts, Constantine wrote: > Michael Conlen wrote: > > >Constantine wrote: > > > >>I am writing a script, which involves unzipping some files. I would > >>have to unzip 4 different zip-files from some directory, and I would > >>need to unzip them to the directory, which would have the same name > >>in it as the original zip-file, i.e. I would like to run something > >>like "ls *.zip", have each file name recorded in some variable, and > >>do a loop like "unzip $filename[$i] -d $filename[$i].unzipped/". Can > >>someone help me with the code? How can I put the results of a command > >>to a variable? > > > >If I understand you properly I think the following would do what you want > > > >#!/bin/sh > >for i in `ls *.zip` > >do > > unzip ${i} -d ${i}.unzipped > >done > > Thank you very much indeed! Seems just what I wanted. But can I save the > archive names in an array for further manipulation? Also, how can I type > that apostrophe ` from my keyboard? For the array I think you do need bash. I'm not familiar with arrays in shell; someone else may be able to help you there. As far as the backquote (`), it seems you answered your own question by typing it into your email. (But the backquote is on the tilde (~) key, if you don't push shift). -- Josh > > Cheers, > Constantine. > > ___ > [EMAIL PROTECTED] mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "[EMAIL PROTECTED]" ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"