Archive for 'Linux' Category

Shrink qemu qcow2 files

By technese - Last updated: Thursday, October 22, 2015

Excerpt from source: Windows Guest 1.Delete all unnecessary files, empty recycle bin 2.Defragment drive (you might need to do this several times, until you see it “compacted” well) 3.Use sdelete to zero free disk space. Please note that this operation will cause that all drive free space will be filled by zero, so the virtual […]

Date formats with Linux

By technese - Last updated: Tuesday, May 1, 2012

$ date +%B” “%d”,”” “%Y May 02, 2012 $ date +”%m-%d-%y” 05-02-12

bash shell tips for filenames

By technese - Last updated: Sunday, February 12, 2012

\\ remove empty files rm -f $(find . -empty) \\ change all filenames from upper to lower case rename ‘y/A-Z/a-z/’ * \\ change all filenames from spaces to underscores find -name “* *” -type f | rename ‘s/ /_/g’

Bash script to create a .m3u from a directory

By technese - Last updated: Friday, November 25, 2011

#!/bin/bash dir=`echo ${PWD##*/}` echo “Create a .m3u playlist for $dir …” ls *.mp3 -1 >> “$dir.m3u” ls *.mp4 -1 >> “$dir.m3u” ls *.m4v -1 >> “$dir.m3u” echo “Found these media files:” cat “$dir.m3u”

using awk to print columns from a file

By technese - Last updated: Monday, November 14, 2011

1st column $ awk ‘{ print $1 }’ < file> newfile 2nd column $ awk ‘{ print $2 }’ < file> newfile nth column $ awk ‘{ print $n }’ < file> newfile

Add Linux swapfile as virtual memory

By technese - Last updated: Friday, November 11, 2011

Add a 1 GByte swapfile: $ dd if=/dev/zero of=/swapfile bs=1M count=1024 $ mkswap /swapfile $ swapon /swapfile to make it available on boot, edit /etc/fstab file and include: /swapfile swap swap defaults 0 0