#!/bin/bash if [ ! $# -eq 2 ]; then echo "You have not inputted the correct amound of arguments. usage: $0 file user Where file is the file to search and user is the user to find" fi if [ ! -e $1 ]; then echo "You have inputted an invalid filename. usage: $ file user Where file is the file to search and user is the user to find" fi let count=0 for line in `cat $1`; do count=`expr $count + 1` if [ "$line" == "$2" ]; then echo "$2 found on line: $count" exit 0 else echo "Would you like to insert this username? y/n" read answer answer=`echo $answer | tr [a-z] [A-Z]` if [ "$answer" != "y" ]; then cat "$answer" >> "/classlist.txt" else echo "That's fine. Program ending ..." exit 0 fi fi done
my "for in" loop doesn't do what it should do. the loop should take data from the text file (btw the text file is just a list of names broken up by line breaks) and assign it to the variable "line." when the "for in" loop ends, it should reassign the "line" variable to the next line in the text file. However, this is not the case. the script only ever reads the first data entry in the text file. did I use the loop incorrectly?