Last active
August 29, 2015 14:06
-
-
Save vinirodr/7c2a21505c566b046805 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
echo -n "Forneça o nome do arquivo a ser verificado: " | |
read arq | |
positive_answer(){ | |
echo "\033[33;32mSim\033[0m" | |
} | |
negative_answer(){ | |
echo "\033[33;31mNão\033[0m" | |
} | |
is_file_present(){ | |
echo -n ' O arquivo existe: ' | |
[ -e $arq ] && positive_answer || negative_answer | |
} | |
can_read(){ | |
echo -n ' Você pode ler o arquivo: ' | |
[ -r $arq ] && positive_answer || negative_answer | |
} | |
can_change(){ | |
echo -n ' Você pode alterar o arquivo: ' | |
[ -w $arq ] && positive_answer || negative_answer | |
} | |
can_run(){ | |
echo -n ' Você pode executar o arquivo: ' | |
[ -x $arq ] && positive_answer || negative_answer | |
} | |
is_file_directory(){ | |
echo -n ' O arquivo é um diretório: ' | |
[ -d $arq ] && positive_answer || negative_answer | |
} | |
is_not_zero_size(){ | |
echo -n 'O arquivo possui tamanho zero: ' | |
[ -s $arq ] && negative_answer || positive_answer | |
} | |
is_a_symbolic_link(){ | |
echo -n 'O arquivo é um link simbólico: ' | |
[ -h $arq ] && positive_answer || negative_answer | |
} | |
are_you_owner(){ | |
echo -n ' Você é o dono do arquivo: ' | |
[ -O $arq ] && positive_answer || negative_answer | |
} | |
full_file_path(){ | |
echo -n ' Caminho absoluto do arquivo: ' | |
echo "\033[33;33m$(readlink -f $arq)\033[0m" | |
} | |
if [ $arq ]; then | |
is_file_present | |
can_read | |
can_change | |
can_run | |
is_file_directory | |
is_not_zero_size | |
is_a_symbolic_link | |
are_you_owner | |
full_file_path | |
else | |
echo 'Você não forneceu o nome do arquivo' | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment