Archive for the ‘Bash’ Category

Loading a Text File Line by Line in a Bash Shell

Thursday, May 13th, 2010

The following example demonstrates how to load a text file into array in a Bash Shell.

#!/bin/sh
count=0
while read line
do
ARR[$count]=$line
((count++))
done < /tmp/infile for LINE in ${ARR[*]} do echo $LINE done