Archive for the ‘Unix’ Category

s3-bash – No newline the secret key file

September 14th, 2009

If you use the s3-bash utilities with Amazon’s S3 service, you’ll find that one of the parameters asks for a file that contains the secret key. There’s important thing to note about this file – it must contain just the secret key without a newline. To check this, listing the file with ls -l should show that the file is 40 bytes. If it’s 41, you’ve got a newline and it won’t work. If you don’t have a text editor handy that will do this for you, you can use the following command to output your secret key to a file without the newline:

echo SECRET_KEY_HERE|tr -d '\n' > secret-key-file

find | xargs grep: hack of the day

September 5th, 2007

Even with today’s modern IDE’s and plethora of search tools (Spotlight, etc.), I still find myself occasionally dropping to a bash shell to look for something in an unknown file. In the past, I was a bit frustrated that my combination of find | xargs grep would bomb out on any files or directories that included a space. Today it dawned on me that there’s a simple workaround for this… Prefix and postfix each file with a quote via sed. The following example recipe will find the text textIAmSearchingFor in any .java file in the current tree.

Read the rest of this entry »

Pipe your current results in less to a file

August 29th, 2007

If you’re ever faced with having piped a long-running process into less, and then you suddenly realize you want to save those results, and don’t want to run that long-running process again, here’s a quick trick to pipe your current results out to a file:

1G (go to the first line)
|$cat – > file.txt (pipe everything to the end of the file to file.txt)

PS – Please comment if you’ve found an easier means to this end.