Skip to content

Instantly share code, notes, and snippets.

@jhyland87
Last active March 23, 2017 18:10
Show Gist options
  • Save jhyland87/7df8cafdfd0007be57ee5e4ba9b8f23e to your computer and use it in GitHub Desktop.
Save jhyland87/7df8cafdfd0007be57ee5e4ba9b8f23e to your computer and use it in GitHub Desktop.
Testing the "file" commands thoroughness
$ echo -e '#!/usr/bin/awk -f\n\n# Just an awk script' | tee test-script.awk
#!/usr/bin/awk -f
# Just an awk script
$ cat test-script.awk
#!/usr/bin/awk -f
# Just an awk script
$ file --mime-type test-script.awk
test-script.awk: text/x-awk
$ mv -v test-script.awk test-script
test-script.awk -> test-script
$ file --mime-type test-script
test-script: text/x-awk
$ echo -e '#!/usr/local/bin/bash \n\n# Just a bash script' | tee test-script.sh
#!/usr/local/bin/bash
# Just a bash script
$ cat test-script.sh
#!/usr/local/bin/bash
# Just a bash script
$ file --mime-type test-script.sh
test-script.sh: text/x-shellscript
$ mv -v test-script.sh test-script
test-script.sh -> test-script
$ file --mime-type test-script
test-script: text/x-shellscript
$ mv -v test-script test-script.awk
test-script -> test-script.awk
$ file --mime-type test-script.awk
test-script.awk: text/x-shellscript
$ file --brief --mime-type test-script.awk
text/x-shellscript
$ echo -e '#!/usr/bin/perl\n\n# Just a perl script' | tee test-script.pl
#!/usr/bin/perl
# Just a perl script
$ file --mime-type test-script.pl
test-script.pl: text/x-perl
$ mv -v test-script.pl test-script.sh
test-script.pl -> test-script.sh
$ file --mime-type test-script.sh
test-script.sh: text/x-perl
$ echo -e '#! /usr/bin/env bash\n\n# Just a bash script using the env bin' | tee test-script.sh
#! /usr/bin/env bash
# Just a bash script using the env bin
$ cat test-script.sh
#! /usr/bin/env bash
# Just a bash script using the env bin
$ file --mime-type test-script.sh
test-script.sh: text/plain
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment