Reputation: 637
[ -r "$df" ] && {
tail -1 $df | grep "$was_fallback" > /dev/null
[ $? -ne 0 ] && { continue; }
This is part of a larger code. I am reading some old codes written by seniors. And then I found this piece of code. I know that [ ] is for 'if' condition. But what is this {} used for?
Upvotes: 2
Views: 143
Reputation: 121427
I know that [ ] is for 'if' condition
No. It's not the if condition. [
is the test command. More about it here:
What is the difference between test, [ and [[ ?
what is this {} used for?
It's called command grouping. From the GNU manual:
{}
{ list; }
Placing a list of commands between curly braces causes the list to be
executed in the current shell context. No subshell is created.
The semicolon (or newline) following list is required.
Upvotes: 3