bash

Show help

Tag(s):

 # Usage info
  show_help() {
  cat << EOF

When script is sourced, how to return or exit code

Tag(s):

When script is sourced, use the following return or exit code

Join 2 files, columns wise

Tag(s):

paste <(cal $(date -d '2 month ago' +'%m %Y')

Print numbers with color: Negative is red and positive is green

#!/bin/bash
set -e
# Description: Print numbers with color: Negative is red and positive is green.
 

Overwrite file if content is different

Tag(s):

# Copy file to destination directory.
#  If file already existed and have different content, then overwrite it.
function F_OVERWRITE_IF_DIFF()
{

Check whether a command is shell builtin or not

Tag(s):

type pwd
#pwd is a shell builtin

To copy faster than cp, use tar|pv|tar

Tag(s):

To copy faster than cp, use tar|pv|tar. See performance benchmark at https://github.com/limelime/mtran/blob/master/benchmark/benchmark-results.md.

Sort multiple columns

Tag(s):

cat people.txt
#   john; smith; 49
#   amanda; bush; 55
#   john; kidman; 55
#   john; bush; -9
#   amanda; bush; 1
 

Get mutiple line text between 2 patterns

Tag(s):

# Note: PATTERN-1 & PATTERN-2 will be also included in your result.
sed -n '/PATTERN-1/,/PATTERN-2/p' input.txt

http://stackoverflow.com/questions/15685471/sed-get-text-between-lines

Pages

Subscribe to RSS - bash