Bash

Bash Script Shebang

#!/usr/bin/env bash

Find/Replace in Directory

find ./ -type f -name "*.yml" -exec sed -i s'/thing1/thing2/g' {} \\;

Git Pull in each Sub Dir

for dir in $(ls); do
    if [[ -d $dir ]]; then
        pushd $dir
            git pull --ff-only
        popd
    fi
done

Bundle install if necessary in each sub-dir

for dir in $(ls); do
    if [[ -d $dir ]]; then
        pushd $dir
            [[ -f "./Gemfile" ]] && (bundle check || bundle install)
        popd
    fi
done

pushd/popd - Got to a directory then return to current after

Work in git root dir

Name and Shame for number of open branches

Run last command until it fails

Run a Command for each Installed version of Ruby

Run rubyfmt on all ruby files

Curl that reports failures as an exit code without output

Use Previous Arguments

!$ uses the last argument from the previous command

Ex:

!* gets ALL the previous args

More Ways to grab args

Last updated

Was this helpful?