Posts Tagged ‘shell’

Articles

Find and replace in all the files

In howto on Nov 17, 2016 by theoryl Tagged: , ,

This simple one liner does it:

find ./ -type f -exec sed -i -e 's/apple/orange/g' {} \;

from StackOverflow

Articles

Parallelize using xargs

In howto on Sep 7, 2016 by theoryl Tagged: , , , ,

According to this answer on StackOverflow: http://unix.stackexchange.com/questions/24954/when-is-xargs-needed/24979#24979 , you can easily parallelize tasks using xargs. To quote the given example:

$ find . -type f -name '*.wav' -print0 | xargs -0 -P 3 -n 1 flac -V8

This example will encode *.wav => *.flac, using three processes at once (-P 3).

Articles

Colors in terminal printout

In howto on Apr 28, 2015 by theoryl Tagged: , ,

A very nice table of the terminal colors on stackoverflow: http://stackoverflow.com/questions/287871/print-in-terminal-with-colors-using-python

Quoting the given example:

class bcolors:
    HEADER = '\033[95m'
    OKBLUE = '\033[94m'
    OKGREEN = '\033[92m'
    WARNING = '\033[93m'
    FAIL = '\033[91m'
    ENDC = '\033[0m'
    BOLD = '\033[1m'
    UNDERLINE = '\033[4m'