Skip to content

Instantly share code, notes, and snippets.

@cpelley
Last active November 4, 2016 08:45
Show Gist options
  • Save cpelley/606142480bdfdf6b8577d341cdccc516 to your computer and use it in GitHub Desktop.
Save cpelley/606142480bdfdf6b8577d341cdccc516 to your computer and use it in GitHub Desktop.
Commandline utility to determine whether the given file is text/binary.
#!/bin/bash
# Function to return whether the specified file is text/binary.
# Returning true/false
#
# Add this file to your PATH to make available and ensure that it has
# executable privileges.
#
# Example usage:
# istext <file>
[[ "$(file -b $1)" == *"text"* ]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment