Advertisement
cd62131

isText

Jul 24th, 2018
486
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.26 KB | None | 0 0
  1. #!/bin/bash
  2. isText() {
  3.   if [[ -f "$1" ]] && file "$1" | grep -q 'text'; then
  4.     return 0
  5.   else
  6.     return 1
  7.   fi
  8. }
  9.  
  10. # test
  11. ls |
  12. while read; do
  13.   if isText "${REPLY}"; then
  14.     echo "${REPLY} is text"
  15.   else
  16.     echo "${REPLY} isn't text"
  17.   fi
  18. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement