Micro-tools: Linux command line find & replace
Sometimes you have to update many files at once. If you are using an IDE there is option during replace “search in all files”. I’ll show you how make those massive changes faster, using just Linux...
View ArticleSimple shell lock implementation on Linux
Sometimes you want to avoid running second instance of some shell script. Locking implementation is not very hard: LOCK_FILE=$0.lock test -f $LOCK_FILE && { PID=`cat $LOCK_FILE` echo...
View ArticlePerforce -> GIT import
I’ve been assigned recently a task to prepare development process for two teams that are working on separate version control systems (GIT and Perforce in my case). One of important parts of this task...
View ArticleSimple SSH services status monitoring
Current project I’m working on benefits from automated test suite run on few Linux-based devices. Tests are running 24×7, but sometimes device hangs (reason is still under investigation) and SSH access...
View ArticleAutomatic free disk space monitoring on Linux server
The simplest way to monitor free disk space on Linux serwer, just place it in crontab: 0 8 * * * df -h | awk '/^\// && $5 > 95 { print "missing space", $0 }' and ensure e-mail to this...
View ArticleGIT hooks: commit-msg to enforce commit rules
Recently I forgot to add #reviewthis directive for modifications of codebase that belongs to team A. And a subtle bug was introduced that way. Ops! I agreed earlier that all changes done to moduleB...
View ArticleHOWTO: cleanup old files under Linux
Sometimes you want to separate old files (for example older than 30 days) into separate subdirectory to make navigation easier. Using Linux tools it’s pretty easy task: mkdir -p OLD; find . -maxdepth 1...
View ArticleLinux: How To Locate Duplicated Files Quickly
Locate duplicates quickly: I mean only size+filename check, not expensive MD5 sum computation: find . -printf "%f:%s:%p\n" -type f | \ awk -F: ' { key=$1 " " $2; occur[key]++; loc[key]=loc[key] $3 " "...
View ArticleIgnore sockets during tar backup
If you want to skip error sockets-related code during backup of whole filesystem you will be surprised there’s no –ignore-sockets switch. But there’s elegant method to to that: cd / sudo find . -type s...
View Article