-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions
More file actions
20 lines (16 loc) · 702 Bytes
/
functions
File metadata and controls
20 lines (16 loc) · 702 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# functions
top10() { history | awk '{a[$2]++ } END{for(i in a){print a[i] " " i}}' | sort -rn | head; }
## file & strings related functions
# find a file with a pattern in name
ff() { find . -type f -iname '*'$*'*' -ls ; }
# find a file with pattern $1 in name and execute $2 on it
fe() { find . -type f -iname '*'$1'*' -exec "${2:-file}" {} \; ; }
# finds directory sizes and lists them for the current directory
dirsize () {
du -shx * .[a-zA-Z0-9_]* 2> /dev/null | egrep '^ *[0-9.]*[MG]' | sort -n > /tmp/list
egrep '^ *[0-9.]*M' /tmp/list
egrep '^ *[0-9.]*G' /tmp/list
rm -rf /tmp/list
}
# ls when cd
function cd() { builtin cd -- "$@" && { [ "$PS1" = "" ] || ls -h --color=auto; }; }