Skip to content

Instantly share code, notes, and snippets.

svn status | grep "^\?" | grep -v ".idea" | awk '{print $2}' | xargs svn add;
svn status | grep "^\!" | awk '{print $2}' | xargs svn rm;
@nikolazic
nikolazic / cron_for_all_users.sh
Created August 12, 2014 15:26
List cron for all users
for user in $(cut -f1 -d: /etc/passwd); do echo $user; crontab -u $user -l; done
@nikolazic
nikolazic / delete_svn_dirs.sh
Created August 1, 2014 20:04
Recursively Delete .svn Directories
find . -type d -name .svn -exec rm -rf {} \;
@nikolazic
nikolazic / disable_apache_mysql.sh
Created July 24, 2014 20:17
Disable Apache and MySQL
sudo sh -c 'echo manual >> /etc/init/mysql.override'
sudo update-rc.d -f apache2 disable
sudo update-rc.d -f x2goserver disable
@nikolazic
nikolazic / recompress_gzip_to_lzma.sh
Last active January 27, 2017 22:18
Recompress all GZIP files into LZMA
find . -name '*.gz' -type f | while read filename; do gzip -cd "$filename" | lzma > "$filename".lzma && rename s/\.gz// *.gz.lzma; done
-OR-
find . -name '*.gz' -type f | while read filename; do gzip -cd "$filename" | lzma > "$filename".lzma && rename .gz.lzma .lzma; done
WITH DELETE
find . -type f -name "*.gz" | while read line ; do echo $line; gunzip --to-stdout "$line" | xz > "$(echo $line | sed 's/gz$/xz/g')"; rm -f "$line"; done
@nikolazic
nikolazic / lines_in_dir
Created June 19, 2014 18:22
Count lines of code in a directory
find . -not -iwholename '*.svn*' -type f | xargs wc -l
@nikolazic
nikolazic / php_remote
Created June 6, 2014 16:03
PhpStorm Dev from Remote Machine
Resources:
(*) http://stackoverflow.com/questions/19204358/vagrant-forwarding-ssh-from-remote-server
(*) http://derickrethans.nl/debugging-with-xdebug-and-firewalls.html
Modify Vagrantfile
# Allow remote connection
config.vm.network :public_network # 2nd interface bridged mode
Reload vagrant
# vagrant reload
@nikolazic
nikolazic / see_files_in_archive.sh
Created May 19, 2014 21:53
See files in archive
tar -tf file.tar
tar -tf file.tar.gz
tar -tf file.tar.bz2
unzip -l file.zip
@nikolazic
nikolazic / filesexist.sh
Created April 28, 2014 19:30
If a file listed in the input file exists echo it to the screen
ip=$1
for i in `cat "$ip"`
do
if [ -r $i ]; then
echo "$i"
fi
done
@nikolazic
nikolazic / gep_unique_exception.sh
Last active February 21, 2017 17:17
Grep unique exception.log or system.log
# (!) On OSX use -E instead of -r
grep '^exception' exception.log | sort | uniq -c | sort -n | less
sed -r s/^[0-9T:+-]+\ ERR\ [\(][0-9]+[\)]:\ // system.log | sort | uniq -c | sort -n | less
sed -r 's#^[0-9]{4}/[0-9]{2}/[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} (WARN|ERROR|INFO) - #\1 #' jmeter-server.log | sort | uniq -c | sort -n | less
sed -r 's#(WARNING|ERROR),[0-9]+,[0-9]+,##' export_products_dev.csv-import.log | sort | uniq -c | sort -n | less
############