Shell script to clean up a project directory
Call geordi clean
from a project root to remove unused and unnecessary files inside it.
This script is part of our geordi gem
on github
Show archive.org snapshot
. In Geordi > 1.2 you can call geordi clean
.
Related cards:
How to send a test e-mail from shell
If you want to manually check if e-mail delivery works on a machine by sending an e-mail you can run the following:
mail -s Test someone@example.com < /dev/null
This will send an empty e-mail with "Test" as its subject to `someone@example.com...
Shell script to quickly switch Apache sites
I prefer the application that I'm currently working on to be reachable at http://localhost/
.
So when I switch to another project, I use this handy shell script to set one site as the current one. Call it just like this:
apache-site makandra...
Grep the number of occurences in a file, counting multiple hits per line
Grep prints one line per match. To return the number if matches, use the -c
switch:
grep -c "something" filename
However, if a word appears more than once in a line, it is only counted once.
To count every match, you can use [sed
](http:...
Script to open an SSH shell to a Capistrano deployment target
We regularly need to connect to the server in order to e.g. access the production console. Guessing the Capistrano deploy user and then again guessing the right directory on the server is awkward, so we wrote a script that parses config/deploy and...
Bash: How to generate a random number within given boundaries
$RANDOM
on bash returns a random integer between 0 and 32767.
echo $RANDOM
9816
echo $RANDOM
30922
If you want to limit that to a certain maximum, you can just compare against the modulus of that maximum + 1. \
For example, the fo...
Solve screen error "Cannot open your terminal '/dev/pts/0' - please check"
When using the screen
tool you may be unable to start a screen session but instead encounter an error:
Cannot open your terminal '/dev/pts/0' - please check.
This is because another user (you) initiated the current terminal -- you probably...
Script to create and copy a production dump to your project root
Soon after having written our shell-for script, we wanted to easily get dumps of our productions machines, too. This is how we do it:
dum...
Linux: Refer to all arguments of a script call
In shell scripts you can use $1
to refer to the first argument, $2
for the second, etc. If you want to refer to all arguments (e.g. when writing a bash script that takes an arbitrary amount of arguments and passes them on to another call), you...
Shell script to generate a Git commit with Pivotal Tracker story ID and title
We usually generate our commit messages from Pivotal Tracker IDs and titles, like
[#15775609] Index view for conflicts
The geordi command commit
automates this. (See: [Pretty Commit messages via geord...
How to move all files in a folder to a new subfolder
Let's say you have a folder images
and want to to move all files in there to a new subfolder public
.
cd images
mkdir public
mv !(public) public
The !(public)
excludes the new subfolder itself from being moved.