Converte permissões de octal para textual e vice-versa
Publicado por Rafael Ancinelo Adolpho (última atualização em 30/06/2014)
[ Hits: 6.293 ]
Homepage: https://www.linkedin.com/in/rafael-adolpho-695b0aa7
Download converte_permissoes.sh
Download 1403705672.converte_permissoes.sh (versão 2)
Shell Script que faz a conversão de permissões no formato OCTAL para TEXTUAL e vice-versa.
Versão 2 - Enviado por Vitor Augusto M. Pio em 25/06/2014
Changelog: Script com o mesmo propósito, porém com a lógica mais bem definida e código mais sucinto.
Download 1403705672.converte_permissoes.sh
#!/bin/bash #Autor radolpho 2012 echo " Escolha com opcao voce deseja (a ou b) a) Octal para texto b) Texto para octal " read resp if [ $resp == a ] ;then #Conversao de OCTAL para TEXTUAL echo "Digite a permissao em OCTAL Ex. 776" read poct #Permissao de user if [ ${poct:0:1} == 0 ] ;then u="---" elif [ ${poct:0:1} == 1 ] ;then u="--x" elif [ ${poct:0:1} == 2 ] ;then u="-w-" elif [ ${poct:0:1} == 3 ] ;then u="-wx" elif [ ${poct:0:1} == 4 ] ;then u="r--" elif [ ${poct:0:1} == 5 ] ;then u="r-x" elif [ ${poct:0:1} == 6 ] ;then u="rw-" elif [ ${poct:0:1} == 7 ] ;then u="rwx" fi #Permissao de group if [ ${poct:1:1} == 0 ] ;then g="---" elif [ ${poct:1:1} == 1 ] ;then g="--x" elif [ ${poct:1:1} == 2 ] ;then g="-w-" elif [ ${poct:1:1} == 3 ] ;then g="-wx" elif [ ${poct:1:1} == 4 ] ;then g="r--" elif [ ${poct:1:1} == 5 ] ;then g="r-x" elif [ ${poct:1:1} == 6 ] ;then g="rw-" elif [ ${poct:1:1} == 7 ] ;then g="rwx" fi #Permissao de other if [ ${poct:2:1} == 0 ] ;then o="---" elif [ ${poct:2:1} == 1 ] ;then o="--x" elif [ ${poct:2:1} == 2 ] ;then o="-w-" elif [ ${poct:2:1} == 3 ] ;then o="-wx" elif [ ${poct:2:1} == 4 ] ;then o="r--" elif [ ${poct:2:1} == 5 ] ;then o="r-x" elif [ ${poct:2:1} == 6 ] ;then o="rw-" elif [ ${poct:2:1} == 7 ] ;then o="rwx" fi echo "Conversao de OCTAL para TEXTUAL\n" echo $poct" >>>> "$u$g$o elif [ $resp == b ] ;then #Conversao de TEXTUAL para OCTAL echo "Digite a permissao em TEXTUAL Ex. rwxrw--w-" read ptxt #Permissao de user if [ ${ptxt:0:3} == "---" ] ;then u="0" elif [ ${ptxt:0:3} == "--x" ] ;then u="1" elif [ ${ptxt:0:3} == "-w-" ] ;then u="2" elif [ ${ptxt:0:3} == "-wx" ] ;then u="3" elif [ ${ptxt:0:3} == "r--" ] ;then u="4" elif [ ${ptxt:0:3} == "r-x" ] ;then u="5" elif [ ${ptxt:0:3} == "rw-" ] ;then u="6" elif [ ${ptxt:0:3} == "rwx" ] ;then u="7" fi #Permissao de group if [ ${ptxt:3:3} == "---" ] ;then g="0" elif [ ${ptxt:3:3} == "--x" ] ;then g="1" elif [ ${ptxt:3:3} == "-w-" ] ;then g="2" elif [ ${ptxt:3:3} == "-wx" ] ;then g="3" elif [ ${ptxt:3:3} == "r--" ] ;then g="4" elif [ ${ptxt:3:3} == "r-x" ] ;then g="5" elif [ ${ptxt:3:3} == "rw-" ] ;then g="6" elif [ ${ptxt:3:3} == "rwx" ] ;then g="7" fi #Permissao de other if [ ${ptxt:6:3} == "---" ] ;then o="0" elif [ ${ptxt:6:3} == "--x" ] ;then o="1" elif [ ${ptxt:6:3} == "-w-" ] ;then o="2" elif [ ${ptxt:6:3} == "-wx" ] ;then o="3" elif [ ${ptxt:6:3} == "r--" ] ;then o="4" elif [ ${ptxt:6:3} == "r-x" ] ;then o="5" elif [ ${ptxt:6:3} == "rw-" ] ;then o="6" elif [ ${ptxt:6:3} == "rwx" ] ;then o="7" fi echo "Conversao de TEXTUAL para OCTAL\n" echo $ptxt" >>>> "$u$g$o fi
Script com Case para e Excluir pastas
Imprimindo textos com o comando "echo"
Baixar aúdios em formato mp3 através de script com o youtube
Conciliando o uso da ZRAM e SWAP em disco na sua máquina
Servidor de Backup com Ubuntu Server 24.04 LTS, RAID e Duplicati (Dell PowerEdge T420)
Visualizar câmeras IP ONVIF no Linux sem necessidade de instalar aplicativos
Converter os repositórios Debian para o novo formato com as chaves
Instalando Spotify no Debian 13
Realizar overclock no Miyoo Mini (plus ou normal)
linux mint reconhece microfone de lapela como fone de ouvido sem micro... (3)
Como desinstalar o GIMP? [RESOLVIDO] (1)