Advertisement
rozman50

Untitled

Mar 17th, 2020
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1.  
  2. function searchPerson {
  3. while IFS= read -r line
  4. do
  5. IFS="|" read -r -a arr <<< "$line"
  6. lineValid=true
  7. # check if $ime is empty, if it is, we are not using it to searching
  8. # [0]-id | [1]-ime | [2]-priimek | [3]-naslov | [4]-posta | [5]-tel
  9. if [ ! -z "$ime" ] && [ "${arr[1]}" != "$ime" ]; then
  10. lineValid=false
  11. fi
  12. if [ ! -z "$priimek" ] && [ "${arr[2]}" != "$priimek" ]; then
  13. lineValid=false
  14. fi
  15. if [ ! -z "$naslov" ] && [ "${arr[3]}" != "$naslov" ]; then
  16. lineValid=false
  17. fi
  18. if [ ! -z "$posta" ] && [ "${arr[4]}" != "$posta" ]; then
  19. lineValid=false
  20. fi
  21. if [ ! -z "$tel" ] && [ "${arr[5]}" != "$tel" ]; then
  22. lineValid=false
  23. fi
  24.  
  25. if [ $lineValid = true ]; then
  26. echo $line
  27. fi
  28.  
  29. done < imenik.dat
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement