shell-script-pt
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [shell-script] Saber se um arquivo é um arquivo texto.


From: Guilherme Gall
Subject: Re: [shell-script] Saber se um arquivo é um arquivo texto.
Date: Tue, 16 Dec 2008 21:57:00 -0200

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Testei o /bin/ls aqui também, da mesma maneira que você e aqui ele foi
considerado arquivo regular.

$ [ -f /bin/ls ] && echo "Arquivo regular"
Arquivo regular

Será que não faltou colar uma linha do terminal?

Quanto ao que é um arquivo regular, acho que os arquivos não regulares
são os de dispositivos.

$ [ -f /dev/stdout ] && echo "Arquivo regular"
$ [ -f /dev/random ] && echo "Arquivo regular"
$ [ -f /etc/passwd ] && echo "Arquivo regular"
Arquivo regular

Saudações,
- --
Guilherme Magalhães Gall (GMGall)
GPG Public Key ID: 0F498058

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: http://getfiregpg.org

iEYEARECAAYFAklIQgAACgkQZV3qXg9JgFhEpgCghTmFM35dfQsiFf62U8Ouznb0
GnoAni1+KuT+fBwT/M/jILuEaC6Nmiuw
=7XIG
-----END PGP SIGNATURE-----

2008/12/16 Eri Ramos Bastos <address@hidden>:
> Na verdade não:
>
> $ [ -f /bin/ls ] && echo "Arquivo regular"
> $ file /bin/ls
> /bin/ls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), for
> GNU/Linux 2.6.8, dynamically linked (uses shared libs), stripped
>
> Acho que o melhor é usar o comando file e testar via "grep -i ascii".
>
> Mas o melhor mesmo é fazer uma checagem melhor no seu script para não
> acontecer de tentar jogar na tela um arquivo binário. :)
>
> []'s
> Eri Ramos Bastos


reply via email to

[Prev in Thread] Current Thread [Next in Thread]