Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi. I'm just going through some scripts at work just for learning purposes.
I'm a bit confused as to what the '!*' command is doing in the second line. What of the previous argument is it giving as output.
When i try to run similar commands and check what the output of '!*' is, it's printing everything after the initial '[[' which doesn't make sense here.
The special meanings of "!" (history) and '*' (file globbing) would be disabled in this context. It looks like it will match any string whose first character is '!'.
Yes, in the RHS of a [[ ]], in a non-interactive script, it matches a string that starts with a ! character.
In order to avoid an unwanted history substitution (for example when testing this in an interactive shell) I would quote the ! character: \!* or "!"* or '!'*
Last edited by MadeInGermany; 01-14-2019 at 05:09 PM.
I don't agree with the explanation from this site:
Quote:
!* Run the previous command except for the last word
Actually, it's quite the opposite. In an interactive context, !* is a shortcut for !!:* which only retrieves all the arguments (i.e. parameter #>0) of the last command saved in history (not the command itself - i.e. parameter #0 - then)...
Example:
Code:
$ ls file1 file2
file1 file2
$ du -hc !*
du -hc file1 file2
8.0K file1
8.0K file2
16K total
But indeed, as explained by smallpond and MadeInGermany, !* has a different meaning in a non-interactive context (! has no special meaning here, it's just a character).
I don't agree with the explanation from this site:
Actually, it's quite the opposite. In an interactive context, !* is a shortcut for !!:* which only retrieves all the arguments (i.e. parameter #>0) of the last command saved in history (not the command itself - i.e. parameter #0 - then)...
Example:
Code:
$ ls file1 file2
file1 file2
$ du -hc !*
du -hc file1 file2
8.0K file1
8.0K file2
16K total
But indeed, as explained by smallpond and MadeInGermany, !* has a different meaning in a non-interactive context (! has no special meaning here, it's just a character).
don't kill the messenger, I just posted what I seen on it, not test it, it is still Greek to me, besides the point.
I've never seen it == !* used in any context, so I just googled on it "! bash" and got what I posted.
I do not know who names there files with a leading !
it does not look like it is seeking inside of a file for a comment that starts with !
^ lol. I didn't say that I didn't agree with something you directly said BW-userx but only with the resource you have posted. No worries
I'm not Leonidas in movie 300 (https://www.youtube.com/watch?v=514IEcgz1Q8), I don't kill messengers
^ lol. I didn't say that I didn't agree with something you directly said BW-userx but only with the resource you have posted. No worries
I'm not Leonidas in movie 300 (https://www.youtube.com/watch?v=514IEcgz1Q8), I don't kill messengers
well that's a relief, I can go back to resting easy.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.