Categories

 

July 2010
M T W T F S S
« Jun    
 1234
567891011
12131415161718
19202122232425
262728293031  

What I'm Doing...

IMG00015.jpgIMG00017.jpgFallColors.jpgSpringFirst snow of the seasonTail Wind

Sending email with a body and attachment from UNIX

It is easy to send a text file as the body of an email from UNIX. You can do it using the command below -

?View Code BASHmail -s "Email with file as body" email@domain.com < message.txt

Now if you want to send a file as an attachment, you would need to use uuencode piped to mail. [...]

  • Share/Bookmark

comment multiple lines in vi

The comment symbol for Unix scripts is typically “#”. You can use the same concept for files for other programming languages. My vi commands below use the “#” symbol.
If you want to comment 5 lines in a file -

Go to the first line you want to comment
Make sure you are in the command mode. [...]

  • Share/Bookmark

Manage directory navigation with pushd and popd

UNIX supports a wide variety of directory-navigation tools. Two good tools are pushd and popd.You’re certainly aware that the cd command changes your current directory. What happens if you have several directories to navigate, but you want to be able to quickly return to a location? The pushd and popd commands create a virtual [...]

  • Share/Bookmark

Reuse previous arguments

Here is another great tip from IBM. I love this. The !$ command returns the last argument used with a command. But what happens if you have a command that used arguments and you want to reuse just one of them? The !:1 operator returns the argument used in a command. The example in [...]

  • Share/Bookmark

Use history expansion

This post is from Unix tips from IBM. What happens if you’re using the same file name for a series of commands? Well, there’s a shortcut that can quickly retrieve the last file name you used.What happens if you’re using the same file name for a series of commands? Well, there’s a shortcut that can [...]

  • Share/Bookmark

Redirect stdout and stderr to same file

I keep forgetting the correct syntax….

% script 2>& logfile

  • Share/Bookmark

More unix find tips

There are so many little things to remember in this command that I always have to lookup what switches to use. So here are a few ways of using find

To find all files modified in the last 24 hours (last full day) in current directory and its sub-directories:

find . -mtime -1 -print

Flag -mtime -1 option [...]

  • Share/Bookmark

Copy and paste in Vi/Vim

This is a neat trick to know and saves a lot of time:

Go to the beginning of the line where you want to start copying.
Make sure you are in the command mode. (Hit ESC).
Type “ma”. Which means, you are marking the spot with “a”.
Go to the line till where you want to copy.
type y`a (yank [...]

  • Share/Bookmark

Tips on unix find

Here is a nice tip on unix find..

$ find . cpio -pdumv /path/to/destination/dir

the files found by find are passed into cpio and it copies the files with the same permissions to the destination directory.

  • Share/Bookmark