slightly confused about '!*' command
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. Code:
[[ "$enabled" == 1 ]] && echo "yes" >${FWRULES_DIR}/$RULEID/Enabled || echo "no" >${FWRULES_DIR}/$RULEID/Enabled Would appreciate any help in understanding the above. Thanks |
I've never seen that one before, this is what I found on the !
Bash Bang (!) commands |
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 '!'* |
Thank you all for the information! Clears things up.
|
Hi.
Thank you all for the information! clears things up. Didn't know there were differences between interactive and non-interactive shell commands. |
Quote:
Quote:
Example: Code:
$ ls file1 file2 |
Quote:
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 ! Interactive and non-interactive shells and scripts |
^ 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 :D |
Quote:
|
All times are GMT -5. The time now is 08:48 AM. |