I have two related questions in a Linux environment.
I am confused when to use backward-slash \
and combining with asterisk "*".
When I try to run Unzip *.zip the command fails until I escape it. Why is it so?
developer@tz:~/f$ bash -version
GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
developer@tz:~/f$ unzip *.zip
Archive: abstract.zip
caution: filename not matched: date-function.zip
developer@tz:~/f$ unzip \*.zip
Archive: abstract.zip
inflating: abstract.xsl
Archive: date-function.zip
warning [date-function.zip]: zipfile is empty
1 archive was successfully processed.
1 archive had warnings but no fatal errors.
developer@tz:~/f$ ls *.zip
abstract.zip date-function.zip
developer@tz:~/f$ ls \*.zip
ls: cannot access '*.zip': No such file or directory
On the similar issue regarding one-liner functions.
Suppose I have zip files: foo.zip and bar.zip in same directory and I need to extract both; when I do:
ls *.zip | xargs -IZIP basename -s .zip ZIP
the above commands will list: foo and bar on konsole, but when I run:
ls *.zip | xargs -IZIP unzip ZIP -d $( basename -s .zip ZIP )
it fails to run because when I pass the results of base, it does NOT get a value, hence it fails.
- When do I use "\" or "*" or combine both when invoking konsole commands?
- How can I extract the zip file to a directory with its own name?
ls
. 2) On my system,unzip(1)
contains a great deal of information under the "Examples" heading. Perhaps the same is true of yours? – Fox Jul 3 '17 at 9:08