1

In a bash shell script, writing a for loop that iterates over string values

view story
linux-howto

http://unix.stackexchange.com – In bash, I know that it is possible to write a for loop in which some loop control variable i iterates over specified integers. For example, I can write a bash shell script that prints the integers between 1 and 10: #!/bin/bash for i in {1..10} do echo $i done Is it possible to instead iterate over a loop control variable that is a string, if I provide a list of strings? For example, suppose that I have a string fname that represents a file name. I want to call a set of commands for each file name. For example, I might want to print the contents of fname using a command like this: # (HowTos)