BASH

How Do I Split An MP3 File For Burning Multiple Tracks To A CD?
Use the mp3splt command line tool. The example below makes 6 minute long tracks.

mp3splt podcast.mp3 -g %[@N=0,@o] -o "@n_@f" -t 6.0

Now you can use the method below to convert all the MP3 files to WAV files, and then burn them to a CD.

How Do I Burn MP3 onto an audio CD from Linux shell command prompt?
First, you need to convert your MP3 (myfile.mp3) into a WAV (myfile.wav) file. You use the mpg123 command line tool for this. Make sure it is stereo. mpg123 --stereo --wav myfile.wav myfile.mp3

Find your CD Burner cdrecord -scanbus

Then burn your WAV file on to the CD cdrecord dev=2,0,0 speed=4 -pad -audio myfile.wav

Or, burn all your WAV files on to the CD (just make sure they are numbered sequentially) cdrecord dev=2,0,0 speed=4 -pad -audio *.wav

Troubleshooting: If you receive this error, then use the --stereo switch shown above to convert it from mono. Inappropriate audio coding in 'myfile.wav'.

http://www.cyberciti.biz/tips/how-do-i-burn-mp3-onto-an-audio-cd-from-command-prompt.html

Number Of Days Between Two Dates
echo $"(( $(date --date="031122" +%s) - $(date --date="021020" +%s) ))/(60*60*24)"|bc

Show Size Of Directories
Sorted by time...

du --time -s */ |sort -k 2

Sorted by size..

du --time -s */ |sort -k 1 -h

Calculator
echo $[1+1]

scale=2; echo "11.45 + 7.95" | bc

Foreach Loop In Script
for i in 1 2 3 do  /usr/bin/nmap -sP -n "192.168.0.$i" |grep 'IP' done
 * 1) !/bin/bash

Extract A Single File From A Tarball Archive
cd /tmp/ tar -xjvpf /path/to/stage4.tar.bz2 etc/conf.d/modules

Create Cool SHA Code From Date (Forum Spam Bot Prevention)
date -u +%jXfce|sha256sum|sed 's/\W//g'

Remove Blank Lines From Text File
cat myfile.txt |sed '/^$/d'

Delete Characters On Just The First Line
This deletes all the quotation (") characters on just the first line of a CSV file...

sed '1s/"//g' /tmp/oldfile.csv > /tmp/newfile.csv

http://sed.sourceforge.net/sed1line.txt

Format A USB Flash Drive With Linux Filesystem
Identify your drive:

cat /proc/partitions dmesg |tail

Repartition drive:

fdisk /dev/sdb d n p 1 [enter] [enter] w

Format drive:

mkfs.ext3 -L "BACKUP-32GB-B" -v /dev/sdb1

Output examples:

thinkpad ~ # dmesg |tail sd 10:0:0:0: [sdb] Assuming drive cache: write through sd 10:0:0:0: [sdb] No Caching mode page present sd 10:0:0:0: [sdb] Assuming drive cache: write through sdb: sdb1 sd 10:0:0:0: [sdb] No Caching mode page present sd 10:0:0:0: [sdb] Assuming drive cache: write through sd 10:0:0:0: [sdb] Attached SCSI removable disk thinkpad ~ # cat /proc/partitions major minor #blocks  name 8       0  312571224 sda 8       1    1228800 sda1 8       2   83103744 sda2 8       3  114118656 sda3 8       4  114109695 sda4 8      16   31696896 sdb thinkpad ~ # fdisk /dev/sdb Command (m for help): p Disk /dev/sdb: 32.5 GB, 32457621504 bytes 64 heads, 32 sectors/track, 30954 cylinders, total 63393792 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xc3072e18 Device Boot     Start         End      Blocks   Id  System Command (m for help): n Partition type: p  primary (0 primary, 0 extended, 4 free) e  extended Select (default p): p Partition number (1-4, default 1): 1 First sector (2048-63393791, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-63393791, default 63393791): Using default value 63393791 Command (m for help): p Disk /dev/sdb: 32.5 GB, 32457621504 bytes 64 heads, 32 sectors/track, 30954 cylinders, total 63393792 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xc3072e18 Device Boot     Start         End      Blocks   Id  System /dev/sdb1           2048    63393791    31695872   83  Linux Command (m for help): w The partition table has been altered! Calling ioctl to re-read partition table. Syncing disks. thinkpad ~ # mkfs.ext3 -L "BACKUP-32GB-B" -v /dev/sdb1 mke2fs 1.42 (29-Nov-2011) fs_types for mke2fs.conf resolution: 'ext3' Filesystem label=BACKUP-32GB-B OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 1982464 inodes, 7923968 blocks 396198 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=4294967296 242 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done thinkpad ~ # umount /media/BACKUP-32GB-B/ thinkpad ~ # fsck.ext3 -v -C0 /dev/sdb1 e2fsck 1.42 (29-Nov-2011) BACKUP-32GB-B: clean, 11/1982464 files, 168470/7923968 blocks

Shell Command Line Calculator
echo 'scale=25;57/43' | bc

http://www.basicallytech.com/blog/index.php?/archives/23-command-line-calculations-using-bc.html

Change History Display Format
export HISTTIMEFORMAT=%Y-%m-%d %H:%M:%S

What Desktop Session Am I Using?
echo $DESKTOP_SESSION

Convert Standard Date And Time To Epoch Time
date +%s

Convert Epoch Time To Standard Date And Time
date --date='@1335309835'

Find And Delete Files
Find any files older than 7 days, then delete them but show what you are deleting.

find /path/to/directory -type f -mtime +7 -exec rm {} \; -print

Find And Copy Files
Find any text files, then copy them to a different directory.

find. -name "*.txt" -exec cp {} /path/to/directory \;

Find And Move Files
Find any text files, then move them to a different directory.

find. -name "*.txt" -exec mv {} /path/to/directory \;

Find The Most Recently Changed Files
find. -type f -printf '%TY-%Tm-%Td %TT %p\n' | sort

Find Empty Directories / Folders
find. -empty -type d

Find All Email Forward Files
find /home/ -maxdepth 2 -type f -name '.forward'

Schedule With AT Command
http://www.brunolinux.com/02-The_Terminal/The_at_Command.html

at 8pm

at midnight tonight

at 3pm tomorrow

To view scheduled 'at' jobs:

atq

To delete scheduled 'at' jobs:

atrm 2

Where '2' is the job number found by using the 'atq' command