Posts Tagged ‘tips’

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

Remove sub directory from Git sparse checkout

In howto on Aug 28, 2014 by theoryl Tagged: , ,

If you have configured Git to use sparse checkout to checkout a sub directory, but later decided that you don’t really need that sub directory, here’s what to do:

1. first delete the sub directory
2. open .git/info/sparse-checkout , delete the sub directory name in the list
3. git read-tree -mu HEAD

If you don’t do this, Git will stage the deletion of the sub directory for the next commit.

Articles

Git aliases

In shared on Jan 17, 2014 by theoryl Tagged: , ,

Some useful Git aliases


[user]
name = ...
email = ...
github = ...

[alias]
a = add
ap = add --patch
am = am -s
c = commit
cs = commit -s
ca = commit --amend
co = checkout
b = branch -vv
l = log --graph --all --abbrev-commit --date=relative --format=format:'%C(bold blue)%h%C(reset) %C(green)%ar %C(yellow)%an%C(bold yellow)%d%C(reset)%n %C(white)%s%n'
lt = log --graph --abbrev-commit --date=relative --format=format:'%C(bold blue)%h%C(reset) %C(green)%ar %C(yellow)%an%C(bold yellow)%d%C(reset)%n %C(white)%s%n'
ll = log --graph --abbrev-commit --date=relative --format=format:'%C(bold blue)%h%C(reset) %C(green)%ar %C(yellow)%an%C(bold yellow)%d%C(reset)%n %C(white)%s%n' -10 HEAD~6..HEAD
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)%Creset' --abbrev-commit --date=relative
lf = log --pretty=fuller
ls = log --pretty=fuller --stat
s = status
d = diff
ds = diff --stat
dc = diff --cached
dcs = diff --cached --stat
dp = show
dhh = diff HEAD^!
dhhs = diff HEAD^! --stat
doh = diff origin/master HEAD
dohs = diff origin/master HEAD --stat
rb = rebase
rbi = rebase -i
rbio = rebase -i origin/master
t = tag -a
tl = tag -ln1

[core]
editor = vim

#[push]
# default = simple

[color]
ui = auto

Articles

Find DOS format text files

In howto on Nov 6, 2013 by theoryl Tagged: ,

From http://stackoverflow.com/questions/73833/how-do-you-search-for-files-containing-dos-line-endings-crlf-with-grep-on-linu :

grep -lUP '\r$' *