{"id":460,"date":"2023-10-27T19:27:50","date_gmt":"2023-10-27T19:27:50","guid":{"rendered":"https:\/\/wp-yoda.com\/en\/?post_type=notices&#038;p=460"},"modified":"2023-10-27T19:30:03","modified_gmt":"2023-10-27T19:30:03","slug":"useful-things-in-bash","status":"publish","type":"notices","link":"https:\/\/wp-yoda.com\/en\/notices\/linux\/bash\/useful-things-in-bash\/","title":{"rendered":"Useful things in Bash"},"content":{"rendered":"\n\n\n<h2 class=\"wp-block-heading\">What is $()<\/h2>\n\n\n\n<p>In a shell script or terminal command, the&nbsp;<code>$()<\/code>&nbsp;syntax is known as &#8220;command substitution.&#8221; It allows you to execute a command and use its output as part of another command or assigned to a variable. In the context of&nbsp;<code>$(docker ps -q)<\/code>, it executes the&nbsp;<code>docker ps -q<\/code>&nbsp;command and captures its output (the container IDs of running containers in this case). Therefore we can combine shell commands.<\/p>\n\n\n\n<p>For example, if\u00a0<code>docker ps -q<\/code>\u00a0returns two container IDs:\u00a0<code>1234abcd<\/code>\u00a0and\u00a0<code>5678efgh<\/code>.<br>Using\u00a0<code>docker stop $(docker ps -q)<\/code>\u00a0is equivalent to running\u00a0<code>docker stop 1234abcd 5678efgh<\/code>. The command substitution allows you to dynamically pass the output of one command as an argument to another command.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is $() In a shell script or terminal command, the&nbsp;$()&nbsp;syntax is known as &#8220;command substitution.&#8221; It allows you to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","format":"standard","meta":{"footnotes":""},"tags":[36,37],"notice_category":[39,38],"class_list":["post-460","notices","type-notices","status-publish","format-standard","hentry","tag-bash","tag-shellscript","notice_category-bash","notice_category-linux"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Useful things in Bash - WP Yoda<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/wp-yoda.com\/en\/notices\/linux\/bash\/useful-things-in-bash\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Useful things in Bash - WP Yoda\" \/>\n<meta property=\"og:description\" content=\"What is $() In a shell script or terminal command, the&nbsp;$()&nbsp;syntax is known as &#8220;command substitution.&#8221; It allows you to [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/wp-yoda.com\/en\/notices\/linux\/bash\/useful-things-in-bash\/\" \/>\n<meta property=\"og:site_name\" content=\"WP Yoda\" \/>\n<meta property=\"article:modified_time\" content=\"2023-10-27T19:30:03+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/notices\\\/linux\\\/bash\\\/useful-things-in-bash\\\/\",\"url\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/notices\\\/linux\\\/bash\\\/useful-things-in-bash\\\/\",\"name\":\"Useful things in Bash - WP Yoda\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/#website\"},\"datePublished\":\"2023-10-27T19:27:50+00:00\",\"dateModified\":\"2023-10-27T19:30:03+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/notices\\\/linux\\\/bash\\\/useful-things-in-bash\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/wp-yoda.com\\\/en\\\/notices\\\/linux\\\/bash\\\/useful-things-in-bash\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/notices\\\/linux\\\/bash\\\/useful-things-in-bash\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Notices\",\"item\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/notices\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Useful things in Bash\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/#website\",\"url\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/\",\"name\":\"WP Yoda\",\"description\":\"Notes about PHP, WordPress and IT\",\"publisher\":{\"@id\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/#organization\",\"name\":\"WP Yoda\",\"url\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2023\\\/05\\\/Andrew_222_Master_Yoda__WordPress_plain_background_763a84a4-5042-4fac-9bdb-4562c05563e7.png\",\"contentUrl\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2023\\\/05\\\/Andrew_222_Master_Yoda__WordPress_plain_background_763a84a4-5042-4fac-9bdb-4562c05563e7.png\",\"width\":1024,\"height\":1024,\"caption\":\"WP Yoda\"},\"image\":{\"@id\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/#\\\/schema\\\/logo\\\/image\\\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Useful things in Bash - WP Yoda","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/wp-yoda.com\/en\/notices\/linux\/bash\/useful-things-in-bash\/","og_locale":"en_US","og_type":"article","og_title":"Useful things in Bash - WP Yoda","og_description":"What is $() In a shell script or terminal command, the&nbsp;$()&nbsp;syntax is known as &#8220;command substitution.&#8221; It allows you to [&hellip;]","og_url":"https:\/\/wp-yoda.com\/en\/notices\/linux\/bash\/useful-things-in-bash\/","og_site_name":"WP Yoda","article_modified_time":"2023-10-27T19:30:03+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/wp-yoda.com\/en\/notices\/linux\/bash\/useful-things-in-bash\/","url":"https:\/\/wp-yoda.com\/en\/notices\/linux\/bash\/useful-things-in-bash\/","name":"Useful things in Bash - WP Yoda","isPartOf":{"@id":"https:\/\/wp-yoda.com\/en\/#website"},"datePublished":"2023-10-27T19:27:50+00:00","dateModified":"2023-10-27T19:30:03+00:00","breadcrumb":{"@id":"https:\/\/wp-yoda.com\/en\/notices\/linux\/bash\/useful-things-in-bash\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/wp-yoda.com\/en\/notices\/linux\/bash\/useful-things-in-bash\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/wp-yoda.com\/en\/notices\/linux\/bash\/useful-things-in-bash\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/wp-yoda.com\/en\/"},{"@type":"ListItem","position":2,"name":"Notices","item":"https:\/\/wp-yoda.com\/en\/notices\/"},{"@type":"ListItem","position":3,"name":"Useful things in Bash"}]},{"@type":"WebSite","@id":"https:\/\/wp-yoda.com\/en\/#website","url":"https:\/\/wp-yoda.com\/en\/","name":"WP Yoda","description":"Notes about PHP, WordPress and IT","publisher":{"@id":"https:\/\/wp-yoda.com\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/wp-yoda.com\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/wp-yoda.com\/en\/#organization","name":"WP Yoda","url":"https:\/\/wp-yoda.com\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/wp-yoda.com\/en\/#\/schema\/logo\/image\/","url":"https:\/\/wp-yoda.com\/en\/wp-content\/uploads\/sites\/2\/2023\/05\/Andrew_222_Master_Yoda__WordPress_plain_background_763a84a4-5042-4fac-9bdb-4562c05563e7.png","contentUrl":"https:\/\/wp-yoda.com\/en\/wp-content\/uploads\/sites\/2\/2023\/05\/Andrew_222_Master_Yoda__WordPress_plain_background_763a84a4-5042-4fac-9bdb-4562c05563e7.png","width":1024,"height":1024,"caption":"WP Yoda"},"image":{"@id":"https:\/\/wp-yoda.com\/en\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/wp-yoda.com\/en\/wp-json\/wp\/v2\/notices\/460","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wp-yoda.com\/en\/wp-json\/wp\/v2\/notices"}],"about":[{"href":"https:\/\/wp-yoda.com\/en\/wp-json\/wp\/v2\/types\/notices"}],"author":[{"embeddable":true,"href":"https:\/\/wp-yoda.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wp-yoda.com\/en\/wp-json\/wp\/v2\/comments?post=460"}],"version-history":[{"count":0,"href":"https:\/\/wp-yoda.com\/en\/wp-json\/wp\/v2\/notices\/460\/revisions"}],"wp:attachment":[{"href":"https:\/\/wp-yoda.com\/en\/wp-json\/wp\/v2\/media?parent=460"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wp-yoda.com\/en\/wp-json\/wp\/v2\/tags?post=460"},{"taxonomy":"notice_category","embeddable":true,"href":"https:\/\/wp-yoda.com\/en\/wp-json\/wp\/v2\/notice_category?post=460"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}