Answers for "bash nested for loop one line"

1

bash nested for loop one line

# Basic syntax:
for i in a b; do for j in c d; do echo $i $j; done; done
# Where:
#	- each do statement has to end with a semicolon. *This is why there is
#		a semicolon after the first done
#	- multiple commands can be passed to each for loop, they just need to be
#		separated by semicolons
#	- for more complex for operations, sometimes it can be helpful to surround
#		the do statements with parentheses, e.g.:
#		for word in $(more words.txt); do (printf "$wordn" & for file in $(ls *); do (grep $word $file -c); done;) done >> output.txt
Posted by: Guest on February-15-2022

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language