Awesome One-liner

Intro

This is a collection of awesome one-liners in shells.

List

  1. Get current BTC price (without demicals) using rate.sx API
curl -s 'rate.sx/1btc?format=qT' | cut -f1 -d\.
  1. Pull all git repo in the folder, including sub-folders (change 3 to dig deeper)
find . -maxdepth 3 -name .git -type d | rev | cut -c 6- | rev | xargs -I {} git -C {} pull
  1. Get the internal WSL IP
ip route |awk '/^default/{print $3}'
  1. Get the Windows host IP from WSL (if generateHosts isn’t set to False in /etc/wsl.conf)
host `hostname` | grep -oP '(\s)\d+(\.\d+){3}' | tail -1 | awk '{ print $NF }' | tr -d '\r'
  1. Convert PDF to PNG using command line
# Make sure `ghostscript` is installed
gs -dBATCH -dNOPAUSE -sDEVICE=pnggray -r300 -dUseCropBox -sOutputFile=item-%03d.png examples.pdf
  1. Get inet IP
ip a | grep inet | cut -d '/' -f 1 | tail -n 2
  1. Delete huge number of files using rsync
mkdir empty && rsync -r --delete empty/ some-dir && rmdir some-dir
  1. Get nightly or any selected release file on GitHub (inspired by Bash: Determining latest GitHub release tag and version)
# Get Citra Nightly Download URL
GITHUB_URL=$(curl --silent --location https://api.github.com/repos/citra-emu/citra-nightly/releases/latest | jq --raw-output ".assets[].browser_download_url" | grep --extended-regexp "citra-linux-.*?.tar.xz")

# A more advanced (read: wicked) one
# Download Sophia-Script Selected Release
curl --silent --location https://api.github.com/repos/farag2/Sophia-Script-for-Windows/releases/latest | jq --raw-output ".assets[].browser_download_url" | grep --extended-regexp "SHA256SUM|10.LTSC.2021|11.v" | xargs wget --quiet --input-file
  1. GitHub Action custom filter
on:
  push:
    branches: ['main']
    # Only run when foo is changed
    paths: ['a-path/foo']

jobs:
  build-that-can-skip:
    runs-on: ubuntu-latest
    # Skip build with [ci skip] in last commit
    if: "! contains(github.event.head_commit.message, '[ci skip]')"

  sensitive-build:
    runs-on: ubuntu-latest
    # Only run on commits with [build]
    if: "contains(toJSON(github.event.head_commit.message), '[build]')"
  1. Create a full git bundle using repository name:
gbc() {
	# Create git bundle using repo name
	git bundle create $(basename `git rev-parse --show-toplevel`).bundle --all
}

Vinfall's Geekademy

VENI VIDI VICI


A collection of awesome one-liners in shells.


Created 2022-09-22
Updated 2023-12-02
Contain 306 words
GPG Key html asc

#crypto #dev #git #ip #linux #wsl