Skip to content

Instantly share code, notes, and snippets.

@quickgrid
Created April 1, 2016 03:09
Show Gist options
  • Save quickgrid/0ec0c1881b3914164ae72c36fb310b60 to your computer and use it in GitHub Desktop.
Save quickgrid/0ec0c1881b3914164ae72c36fb310b60 to your computer and use it in GitHub Desktop.
Reads the input file line by line in while loop then checks if the number is even or odd using if condition and finally prints even lines.
#!/bin/bash
i=1
while read line
do
var=$(( $i % 2 ))
if [ $var -eq 0 ]; then
echo "$line"
fi
i=$(( $i + 1 ))
done < "FaxNumbers.txt"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment