Archive for 'Linux' Category

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