All pastes #516991 Raw Edit

nameless

public shellscript v1 · immutable
#516991 ·published 2007-05-28 22:37 UTC
rendered paste body
while true; do echo -n "Give me the code of that house: "     read code ;      namef=$(awk NR==1'{print $5}' apartments_file)     if grep -q " $code $" apartments_file;               then echo "There is already a house named $namef with that code." ;                   echo -n "Please try again: ";     else echo "Apartment name: $name with code $code" >>    apartments_file;      echo "Apartment name: $name with code $code added successfully."      break        fi ;       done ;    break ;[simeon@localhost project]$ cat apartments_fileName of the apartment:  "house1" with code :: 90 Name of the apartment:  "house2!" with code :: 80 Name of the apartment: "rush hour" with code :: 100 Name of the apartment: "fly away" :: 10 Name of the apartment: "flying high" :: 20 Name of the apartment: "into the summer sky" with code :: 50 and some output of the script:**********************Adding a new apartment...**********************Give me the name of the apartment house: same_house_testingGive me the code of that house: 90There is already a house named "house1" with that code.Please try again: Give me the code of that house: 90There is already a house named "house1" with that code.Please try again: Give me the code of that house: 100There is already a house named "house1" with that code.Please try again: Give me the code of that house: