Aaron Rainbolt on Nostr: You can run multiple commands as a single "block" in Bash using C-style braces. This ...
You can run multiple commands as a single "block" in Bash using C-style braces. This can be useful for error handling - you can do things like "cd /mydir || { echo "could not cd to /mydir"; exit 1;};" Make sure to remember the semicolon on the last command before the closing brace though, or Bash won't be able to figure out where the block ends.
#linux #bash #shell #scripting
Published at
2024-06-27 18:04:35Event JSON
{
"id": "012b1b5949d4a794abb174b8488c7df82ed06295289802019f473c8232b3cf61",
"pubkey": "b764dfce4744790ecaba851b29af6750c60a24d3792a14a8912039f0fb5becf1",
"created_at": 1719511475,
"kind": 1,
"tags": [
[
"t",
"linux"
],
[
"t",
"bash"
],
[
"t",
"shell"
],
[
"t",
"scripting"
],
[
"proxy",
"https://theres.life/users/arraybolt3/statuses/112689904058465356",
"activitypub"
]
],
"content": "You can run multiple commands as a single \"block\" in Bash using C-style braces. This can be useful for error handling - you can do things like \"cd /mydir || { echo \"could not cd to /mydir\"; exit 1;};\" Make sure to remember the semicolon on the last command before the closing brace though, or Bash won't be able to figure out where the block ends.\n\n#linux #bash #shell #scripting",
"sig": "9859857fbb01c8d19c25e7c7d17efc24656f6a5edff980a51f033cbf636118d4feeb4ec842fbf54e4a47130377c447669bee02b743e1eed4212b10245a1a27f5"
}