Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- isText() {
- if [[ -f "$1" ]] && file "$1" | grep -q 'text'; then
- return 0
- else
- return 1
- fi
- }
- # test
- ls |
- while read; do
- if isText "${REPLY}"; then
- echo "${REPLY} is text"
- else
- echo "${REPLY} isn't text"
- fi
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement