Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Peter Cooperx http://www.petercooper.co.uk/

« Newer Snippets
Older Snippets »
Showing 1-4 of 4 total  RSS 

Mail a file as an attachment from the UNIX prompt

   1  uuencode file.txt file.txt | mail email@address.com

Easy file encryption and decryption from the shell

Works on OS X, Linux, anywhere with OpenSSL installed:

To encrypt a file:
   1  openssl des3 -salt -in infile.txt -out encryptedfile.txt


To decrypt the file:
   1  openssl des3 -d -salt -in encryptedfile.txt -out normalfile.txt


Do not specify the same file as input and output on encryption.. I have noticed weird effects on OS X (it eats the file). Remove the -in * stuff if you want to pipe data into it (e.g. a tarred folder). Omit the -out * stuff if you want it to pipe data out on STDOUT.

Change file extensions with bash shell

To change all .htm files in a folder to .html files:

   1  for f in *.htm; do mv $f `basename $f .htm`.html; done;

bash shell directory shortcuts

Go back to your previous directory:

   1  cd -


Go to a new directory and push the current one onto a stack:

   1  pushd /newdirectory


Pop a directory from the stack and go to it:

   1  popd
« Newer Snippets
Older Snippets »
Showing 1-4 of 4 total  RSS