🐚

Shell oneliners (occasionally updated)

1 min read

Download Redmine project's issue PDFs in one go

curl -sH 'X-Redmine-API-Key:<Redmine API Key goes here>' https://redmine.example.com/projects/project_path/issues.csv?encoding=UTF-8 \
  | sed -rne's/^([0-9]*),.+$/\1/p' \
  | xargs -I {} -n 1 curl -sOJH 'X-Redmine-API-Key:<Redmine API Key goes here>' https://redmine.example.com/issues/{}.pdf

Count text file lines and chars in a git repository

find -type d -name .git -prune \
  -o -type f -exec sh -c "file -b {} | grep -Pq 'JSON|text'" \;
  -exec cat {} \; | wc

Search multiple archived logs and append file names each line of the output

ls *.log.1.gz | \
  xargs -n 1 -I {} sh -c '
    zcat -f {} | \
    sed -re"s/^/{}: /" \
  ' | \
  grep -iP '<search pattern>' | \
  less -I

View json log with jq formatted and with color

zcat whatever-json.log.1.gz | \
  grep -iP '<search pattern>' | \
  jq -C . | \
  less -RI

Discussion

ログインするとコメントできます