Open main menu

CDOT Wiki β

Changes

Tutorial12: Shell Scripting - Part 2

No change in size, 09:24, 27 July 2020
Additional Loop Statements
===Additional Loop Statements===
[[Image:for-command-substitution.png|thumb|right|300px|Example of how a '''for loop with command substitution''' works.]]'''Command Substitution'''
command substitution is a facility that allows a command<br>to be run and its output to be pasted back on the command line as arguments to another command.<br>Reference: https://en.wikipedia.org/wiki/Command_substitution
[[Image:for-command-substitution.png|thumb|right|300px|Example of how a '''for loop with command substitution''' works.]]'''for Loop using Command Substitution'''
Let’s issue the for loop with a list using command substitution.<br>In the example below, we will use command substitution to issue the ls command and<br>have that output (filenames) become arguments for the for loop.
13,420
edits