Categories

 

February 2012
M T W T F S S
« Oct    
 12345
6789101112
13141516171819
20212223242526
272829  

What I'm Doing...

PlaytimePriya and KunalIMG00015.jpgIMG00017.jpgFallColors.jpgSpring

Argument list too long

Ever tried to copy or move a bunch of files on unix/linux from one location to another and see this error message spit out back at you??

$ cp /var/www/* /var/tmp
-bash: /bin/cp: Argument list too long

UNIX find to the rescue…

$ find /var/www -type f -name ‘*’ -exec cp {} /var/tmp/. \;

problem solved!

Share

SSH aliases

I constantly connect to linux or unix machines using ssh and it can get a little bothersome typing out the IP address repeatedly. Here is the typical syntax to connect to a linux box (random IP address)

ssh username@111.11.11.1

Now imagine typing this again and again. Thats where the ssh config file comes to the rescue. You [...]

Share

Unix tar tricks

One of the most common programs on Linux systems for packaging files is the venerable tar. tar is short for tape archive, and originally, it would archive your files to a tape device. Now, you’re more likely to use a file to make your archive. To use a tarfile, use the command-line option -f . [...]

Share

Grep for multiple stuff in one file

Update: See the comments to see how to do this correctly.

the UNIX grep command is very powerful, but the egrep command is even more powerful. You can grep for multiple strings in a file using the egrep command. All you have to do is use the | (or) symbol and add as many strings you [...]

Share

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

mail -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. This file can [...]

Share

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

FTP multiple files without prompt

I knew there was a way to ftp multiple files without being prompted.It was just a matter of knowing the syntax.

It is possible to download several files at once, using the mget command. This command can take several filenames as arguments, and you can even use wildcards to download matching files. For example, the command

mget [...]

Share

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

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

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