Advertisement
MrRockchip

morestuff

Jan 5th, 2024
20
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. # Prints the lines of a file '$2' which contain the text '$1'.
  2. grepper () {
  3. if [ -f "$2" ] ; then
  4. custom_input=$(cat "$2")
  5. else
  6. custom_input="$($2)"
  7. fi
  8. printf "$custom_input\n" | while IFS= read -r grepper_line
  9. do
  10. case "$grepper_line" in
  11. *"$1"*)
  12. printf '%s\n' "$grepper_line"
  13. ;;
  14. esac
  15. done
  16. return 0
  17. }
  18.  
  19. grepper "$1" "$2"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement