Ctrl + A Go to the beginning of the line you are currently typing on
Ctrl + E Go to the end of the line you are currently typing on
Ctrl + L Clears the Screen, similar to the clear command
Ctrl + U Clears the line before the cursor position. If you are at the end of the line, clears the entire line.
Ctrl + H Same as backspace
Ctrl + R Let’s you search through previously used commands
Ctrl + C Kill whatever you are running
Ctrl + D Exit the current shell
Ctrl + Z Puts whatever you are running into a suspended background process. fg restores it.
Ctrl + W Delete the word before the cursor
Ctrl + K Clear the line after the cursor
Ctrl + T Swap the last two characters before the cursor
Esc + T Swap the last two words before the cursor
Alt + F Move cursor forward one word on the current line
Alt + B Move cursor backward one word on the current line
Tab Auto-complete files and folder names
—Mac OSX Bash shortcuts
temp dir cleaner
I’ve just released one of the my scripts I use on my computers (laptops and servers).
I developed the first version of this simple script some years ago.. it was useful to keep clean a shared temporary directory of an internal server we used for file transfers.
Then, for some reasons, I simply lost it. Some months ago I decided to rewrite it, to automatically delete old temporary files on my laptop, since I started using “sleep” over “shut down”..
Now it’s hosted on github!
simple mongo db backup script
Yesterday I was developing a new feature on Mashape and I wanted to backup my local DB.
So I wrote a small script to backup data of a list of sb (variable $DB) in a folder db-20110115 and to have it replicated on another pc in my LAN (just in case..) via ssh (with rsa key to be scheduled in cron).
#!/bin/bash
# CONFIGURATION
DBS=”db1 db2”
DUMP_LOCATION=~/backup
DIR_NAME=db-`date +%Y%m%d`
DIR_NAME_ABS=$DUMP_LOCATION/$DIR_NAME
COPY_SSH_DEST=server1:$DIR_NAME_ABS
##—
echo “Starting backup `date`”
for DB in $DBS
do
echo “Backup: $DB”
mongodump —db $DB —out $DIR_NAME_ABS
done
scp -r $DIR_NAME_ABS $COPY_SSH_DEST
echo “Backup Finished `date`”
If anyone is interested I plan to add compression and auto delete of data after two months