Wednesday, November 25, 2009

iterating through lines in a file in bash

quick bash script to allow you to iterate through lines in a file

#!/bin/bash

cat filename | while read line; do
echo $line
done


another way:

#!/bin/bash

IFS=$'\n'
for line in $(cat filename); do
echo $line
done

0 Comments:

Post a Comment

<< Home