find . -ctime -3# created in the past 3 daysfind . -ctime +3# older than 3 daysfind . -ctime 3# created exactly 3 days backfind . -ctime +3 -ctime -5# created 3 – 5 days backfind . -newer /tmp/somefile# see somefile’s timestamp and show files newer than it- works great in conjunction with:
touch 0607090016 /tmp/somefile#i.e. 7th june, 9:00 am, 2016find . -maxdepth 1 -type d -ctime +38 -exec rm -rf {} \;delete all folders older than 38 days back.- don’t use atime much: every directory access changes its atime, so when find traverses through it, the inode’s atime entry gets updated.
Tag: linux
GNU Screen & Tmux notes
GNU/Screen splitting windows
C-a V or C-a |split the screen verticallyC-a Xremove/detach the current splitC-a Ssplit horizontallyC-a tabcycle between windows
Tmux keybindings
Ctrl-b %(Split the window vertically)Ctrl-b :“split-window” (Split window horizontally)Ctrl-b o(Goto next pane)Ctrl-b q(Show pane numbers, when the numbers show up type the key to goto that pane)Ctrl-b {(Move the current pane left)Ctrl-b }(Move the current pane right)
And here’s my .tmux.conf
set -g prefix C-a
unbind C-b
bind C-a send-prefix
set -g default-terminal "xterm-256color"
set -g history-limit 10000
set -g set-titles-string "#T"
unbind %
bind | split-window -h
bind - split-window -v
Look up files that are deleted but not reclaimed
sudo /usr/sbin/lsof | grep deleted
- Space will not be freed for the files there.
- Restart those offending daemons to actually free the space up.
If you don’t have lsof, just use this:
find /proc/*/fd -ls | grep '(deleted)'
Colours in Terminals
arunsrin@ARUNSRIN-G2CA5 MINGW64 ~
$ printf "\033[32mhi\033[0m"
hi
\033is Escape- So
Escape + 3 + 2 + mtells the terminal that everything from this point onwards is in green. -
And
Escape + [ + 0 + mreverts it back to normal - These are some sequences:
Sequence What it Does
ESC[1m Bold, intensify foreground
ESC[4m Underscore
ESC[5m Blink
ESC[7m Reverse video
ESC[0m All attributes off
find / xargs when filenames have spaces
findhas a print0 option that uses null characters instead of \n as separators.xargshas a -0 option that uses the same separator when working on the args. So:
find . -name -print0 | xargs -0 ls -l
diff and patch
cp -r somepackage somepackage-new
# make changes in somepackage-new
diff -ruN somepackage somepackage-new > mychanges.patch
# give the patch to someone else, who can now do:
cd somepackage
patch -p1 < mychanges.patch
More information than you’ll ever need here.