Check These Out
sudo ipfw pipe 1 config bw 50KByte/s
Set the bandwidth (bw) limit to any number you want. For example you could have a 15kb pipe for X application and then a 100kb pipe for another application and attach things to those pipes. If a port isn’t attached to a pipe, it runs at full speed. Change the number (in this case 1) to a different number for a different pipe.
The next step is to attach your port.
sudo ipfw add 1 pipe 1 src-port 80
In this case anything on port 80 (http) will be set to a limit of 50Kbyte/s. If you want to attach a second port to this pipe, repeat the command but change the port number at the end.
src : http://www.mactricksandtips.com/2008/12/throttling-bandwidth-on-a-mac.html
using find's exec option instead of a for loop and using sed's -i option for inplace replacement. no need to do the file swap.
short, sweet, and works after sudoing a new shell.
If you just want to write or append some text to a file without having to run a text editor, run this command. After running the command, start typing away. To exit, type . on a line by itself.
Replacing the >> with a single > will let you overwrite your file.
Find files in a specific date range - in this case, the first half of last year.
-newermt = modification time of the file is more recent than this date
GNU find allows any date specfication that GNU date would accept, e.g.
$ find . -type f -newermt "3 years ago" ! -newermt "2 years ago"
or
$ find . -type f -newermt "last monday"
Optimal way of deleting huge numbers of files
Using -delete is faster than:
$ find /path/to/dir -type f -print0 | xargs -0 rm
$ find /path/to/dir -type f -exec rm {} +
$ find /path/to/dir -type f -exec rm \-f {} \;
While a dd is running in one terminal, open another and enter the while loop. The sample output will be displayed in the window running the dd and the while loop will exit when the dd is complete. It's possible that a "sudo" will need to be inserted before "pkill", depending on your setup, for example:
$ while pgrep ^dd; do sudo pkill -INFO dd; sleep 10; done
Using this command you can track a moment when usb device was attached.
stty sane resets the tty to basic usable function. The ^J is a newline -- sometimes CR/LF interpretation is broken so use the ^J explicitly.