shell script: read in values from text file

before i forget how to do this again assuming test.txt contains a number on each line, ie.

123
324
45656

heres a couple of simple ways to read from the file and so stuff in a shell script

#!/bin/bash
INFILE=test.txt
OUTFILE=out.xml
for i in $(cat $INFILE) ; do
     #do some stuff
     echo item: $i
done

or use

while read line
    do
        echo $line;
done < $INFILE

(echo "</oai_dc:dc>" >> $OUTFILE )

Justin Kelly

Justin Kelly

Data Engineeer, Business Analytics, Web Developer, Library Technology specialising in PHP and Tableau

Based in Melbourne, Australia

Feel free to contact me justin@kelly.org.au or _justin_kelly