Check These Out
For automated unit tests I wanted my program to run normally, but if it crashed, to add a stack trace to the output log. I came up with this command so I wouldn't have to mess around with core files.
The one downside is that it does smoosh your program's stderr and stdout together.
The "date' command has options to easily format the date, day, month, time, etc. But what if you want a relative date or time. Like, I wanted yesterday's date in a particular format. You may want the exact date of "2 months ago" or "-3 days" nicely formatted. For that, you can use this command. The --date option takes fuzzy parameters like the ones mentioned in the previous sentence.
Particularly useful on OS X where netstat doesn't have -p option.
Find all files that contain string XXX in them, change the string from XXX to YYY, make a backup copy of the file and save a list of files changed in /tmp/fileschanged.
Removes ANSI color and end of line codes to the [{attr1};...;{attrn}m format.
Show's per IP of how many requests they did to the Apache webserver
This inserts an element as last child under /breakfast_menu/food in simple.xml.
xml used - http://www.w3schools.com/xml/simple.xml
This can be particularly useful used in conjunction with a following cut command like
$echo "hello::::there" | tr -s ':' | cut -d':' -f2
which prints 'there'. Much easier that guessing at -f values for cut. I know 'tr -s' is used in lots of commands here already but I just figured out the -s flag and thought it deserved to be highlighted :)
Test your XFS filesystem and Raptor hard drives for write performance.
This is just a proof of concept: A FILE WHICH CAN AUTOMOUNT ITSELF through a SIMPLY ENCODED script. It takes advantage of the OFFSET option of mount, and uses it as a password (see that 9191? just change it to something similar, around 9k). It works fine, mounts, gets modified, updated, and can be moved by just copying it.
USAGE: SEE SAMPLE OUTPUT
The file is composed of three parts:
a) The legible script (about 242 bytes)
b) A random text fill to reach the OFFSET size (equals PASSWORD minus 242)
c) The actual filesystem
Logically, (a)+(b) = PASSWORD, that means OFFSET, and mount uses that option.
PLEASE NOTE: THIS IS NOT AN ENCRYPTED FILESYSTEM. To improve it, it can be mounted with a better encryption script and used with encfs or cryptfs. The idea was just to test the concept... with one line :)
It applies the original idea of http://www.commandlinefu.com/commands/view/7382/command-for-john-cons for encrypting the file.
The embedded bash script can be grown, of course, and the offset recalculation goes fine. I have my own version with bash --init-file to startup a bashrc with a well-defined environment, aliases, variables.