Skip to content

Instantly share code, notes, and snippets.

@Dirack
Last active July 13, 2019 05:03
Show Gist options
  • Select an option

  • Save Dirack/a3c6a3d10ea55ec43ca124484950c214 to your computer and use it in GitHub Desktop.

Select an option

Save Dirack/a3c6a3d10ea55ec43ca124484950c214 to your computer and use it in GitHub Desktop.
Lista de comandos do linux que estou estudando

Cursor Movement

ANSI escape sequences allow you to move the cursor around the screen at will. This is more useful for full screen user interfaces generated by shell scripts, but can also be used in prompts. The movement escape sequences are as follows:

  • Position the Cursor: \033[;H Or \033[;f puts the cursor at line L and column C.

  • Move the cursor up N lines: \033[A

  • Move the cursor down N lines: \033[B

  • Move the cursor forward N columns: \033[C

  • Move the cursor backward N columns: \033[D

  • Clear the screen, move to (0,0): \033[2J

  • Erase to end of line: \033[K

  • Save cursor position: \033[s

  • Restore cursor position: \033[u

Comando TAR

Comando para empacotar arquivos no linux ubuntu. Apenas empacota, por padrão, não comprime.

tar [opções] [arquivo.tar] [arquivo origem]
  • -c Cria novo tar

  • -t Exibe o conteúdo de um tar

  • -r Adiciona aquivos a um tar existente

  • -x Extrair

  • -f Especificar saída

  • --delete Remover arquivo dentro do tar

  • Exemplos de Uso:

~$ tar -cf planta.tar arquivo.txt teste1.txt teste2.txt
~$ tar -f planta.tar --delete arquivo.txt
  • Para comprimir arquivos com tar:
~$ tar -czf arquivo.tar.gz arquivo.txt teste1.txt
~$ tar -cjf arquivo.tar.bz arquivo.txt teste1.txt
  • Para descomprimir arquivos com tar:
~$ tar -xzf arquivo.tar.gz
~$ tar -xjf arquivo.tar.bz
  • Verificar o tamanho dos arquivos comprimidos:
~$ du -ha

Variável Descrição

  • $0 Parâmetro número 0 (nome do comando ou função)
  • $1 Parâmetro número 1 (da linha de comando ou função)
  • ... Parâmetro número N (da linha de comando ou função)
  • $9 Parâmetro número 9 (da linha de comando ou função)
  • ${10} Parâmetro número 10 (da linha de comando ou função)
  • $# Número total de parâmetros da linha de comando ou função
  • $* Todos os parâmetros, como uma string única
  • $@ Todos os parâmetros, como várias strings protegidas
  • $$ PID do processo atual (do próprio script)
  • $! PID do último processo em segundo plano
  • $_ Último argumento do último comando executado
  • $? Valor de retorno do último comando executado
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment