Advertisement
Guest User

Injiil

a guest
Sep 26th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. Remove()
  2. {
  3. echo "Remove"
  4. echo "Please enter the surename of the record you want to remove(case sensitive):"
  5. read remove
  6. grep -n "$remove" book.txt
  7. status=`echo $?`
  8. if [ $status -eq 1 ]
  9. then
  10. echo "No records found for \"$remove\""
  11. else
  12. echo "Enter the line number of the record you want to remove."
  13. read remL
  14. for line in grep -n "$remove" book.txt
  15. do
  16. number=`echo "$line" | cut -c1`
  17. if [ $number -eq $remL ]
  18. then
  19. lineRemove="${remL}d"
  20. sed -i -e "$lineRemove" book.txt
  21. echo "The record was successfully removed!"
  22. fi
  23. done
  24. fi
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement