Skip to content

artubss/SKILLS-CLAUDE-CODE / skills/skills/development/bash-linux

bash-linux

Unverified

Padrões de terminal Bash/Linux. Comandos críticos, piping, tratamento de erros, scripting. Use ao trabalhar em sistemas macOS ou Linux.

Padrões Bash Linux

Padrões essenciais para Bash em Linux/macOS.


1. Sintaxe de Operadores

Encadeamento de Comandos

OperadorSignificadoExemplo
;Executar sequencialmentecmd1; cmd2
&&Executar se anterior sucedeunpm install && npm run dev
||Executar se anterior falhounpm test || echo "Tests failed"
|Pipe de saídals | grep ".js"

2. Operações com Arquivos

Comandos Essenciais

TarefaComando
Listar tudols -la
Encontrar arquivosfind . -name "*.js" -type f
Conteúdo do arquivocat file.txt
Primeiras N linhashead -n 20 file.txt
Últimas N linhastail -n 20 file.txt
Seguir logtail -f log.txt
Buscar em arquivosgrep -r "pattern" --include="*.js"
Tamanho do arquivodu -sh *
Uso de discodf -h

3. Gerenciamento de Processos

TarefaComando
Listar processosps aux
Encontrar por nomeps aux | grep node
Matar por PIDkill -9 <PID>
Encontrar usuário da portalsof -i :3000
Matar portakill -9 $(lsof -t -i :3000)
Backgroundnpm run dev &
Jobsjobs -l
Trazer para frentefg %1

4. Processamento de Texto

Ferramentas Principais

FerramentaPropósitoExemplo
grepBuscargrep -rn "TODO" src/
sedSubstituirsed -i 's/old/new/g' file.txt
awkExtrair colunasawk '{print $1}' file.txt
cutCortar camposcut -d',' -f1 data.csv
sortOrdenar linhassort -u file.txt
uniqLinhas únicassort file.txt | uniq -c
wcContarwc -l file.txt

5. Variáveis de Ambiente

TarefaComando
Ver todasenv ou printenv
Ver umaecho $PATH
Definir temporariamenteexport VAR="value"
Definir em scriptVAR="value" command
Adicionar ao PATHexport PATH="$PATH:/new/path"

6. Rede

TarefaComando
Downloadcurl -O https://example.com/file
Requisição APIcurl -X GET https://api.example.com
POST JSONcurl -X POST -H "Content-Type: application/json" -d '{"key":"value"}' URL
Verificar portanc -zv localhost 3000
Informações de redeifconfig ou ip addr

7. Template de Script

#!/bin/bash
set -euo pipefail  # Exit on error, undefined var, pipe fail

# Colors (optional)
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m'

# Script directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

# Functions
log_info() { echo -e "${GREEN}[INFO]${NC} $1"; }
log_error() { echo -e "${RED}[ERROR]${NC} $1" >&2; }

# Main
main() {
    log_info "Starting..."
    # Your logic here
    log_info "Done!"
}

main "$@"

8. Padrões Comuns

Verificar se comando existe

if command -v node &> /dev/null; then
    echo "Node is installed"
fi

Valor padrão de variável

NAME=${1:-"default_value"}

Ler arquivo linha por linha

while IFS= read -r line; do
    echo "$line"
done < file.txt

Loop sobre arquivos

for file in *.js; do
    echo "Processing $file"
done

9. Diferenças do PowerShell

TarefaPowerShellBash
Listar arquivosGet-ChildItemls -la
Encontrar arquivosGet-ChildItem -Recursefind . -type f
Ambiente$env:VAR$VAR
Concatenação string"$a$b""$a$b" (igual)
Verificar nuloif ($x)if [ -n "$x" ]
PipelineBaseado em objetoBaseado em texto

10. Tratamento de Erros

Definir opções

set -e          # Exit on error
set -u          # Exit on undefined variable
set -o pipefail # Exit on pipe failure
set -x          # Debug: print commands

Trap para limpeza

cleanup() {
    echo "Cleaning up..."
    rm -f /tmp/tempfile
}
trap cleanup EXIT

Lembre-se: Bash é baseado em texto. Use && para cadeias de sucesso, set -e para segurança, e sempre coloque aspas em suas variáveis!

slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 196kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 192kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 192kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 192kUpdated Claude CodeCodexVerifiedInstall