Files
CodeSnippets/bash/one_liners.bash
2023-03-07 15:00:21 +10:30

12 lines
659 B
Bash

#!/usr/bin/env bash
# How to strip leading "./" in "find"
find -type f -printf '%P\n'
# From find manual: %P File's name with the name of the command line argument under which it was found removed.
# Get a grep command to not find itself
<command> | grep '[p]attern'
# will find instances of 'pattern' in the output of <command> but not the grep command itself.
# Ref: https://stackoverflow.com/questions/20528894/how-does-ps-aux-grep-pattern-exclude-grep-itself
# The pattern "[p]attern" will not match the literal string "[p]attern". Instead it will match strings
# with exactly one char from the 1-character class "[p]", followed by "attern".