user-avatar
Today is Friday
April 19, 2024

Tag: command

August 8, 2011

How to use mail command to mail the contents of the file to somebody

by viggy — Categories: FOSS, linux, programming, shell, tech — Tags: , , Leave a comment

$cat “Filename” | mail -s “subject” “mailid”

The assumption here is that you have sendmail configured in the system and the mailid that you have provided accepts mails from unknown addresses. Gmail doesnt.

August 6, 2010

January 13, 2010

split and join huge files

by viggy — Categories: linux, Misc, tech — Tags: , , , , , , Leave a comment

I recently has asked my friend to download edubuntu9.10 iso . It was a 3.4 gb iso. After he finished downloading when i had to transfer it to my system, we faced a small problem. His LAN card was not working and we had only 1gb pen drive. So the only option we had was to split the iso into files of size 1gb and then transfer them using pen drive.

command to split a huge file into smaller file.

split -b 1G

is the prefix of the smaller files that will be created.

After I split the files, i transfered each file in to my system and then joined the files using a very simple “cat” command.

Join the files splitted by the above commad.

$cat aa bb cc dd>huge-filename

The above command will join all the files and create the file huge-filename.

I need to test whether the order of the smaller files matters in the cat command. Logic says that it should matter. lemme check it out.

Confirmed it. The order of the smaller files is very importent to get back the original file.

November 9, 2009

Using sed

by viggy — Categories: tech — Tags: , , Leave a comment

How to use sed command to remove lines from a file which match a particular pattern.

sed ‘//d’ file-name > tmp

This command will delete all the lines from the file which match the pattern and then store the contents in the ‘tmp’ file.

How to use sed command to substitute strings which match a pattern and then replace it with another string?

sed -e ‘s///’

This command is to match a string and replace it with another string. The new contents of the will be stored in

How to use a pattern matched in sed command also in the replaced string?

Use & to substitute the matched string.

July 17, 2009

cd // ??

by viggy — Categories: Uncategorized — Tags: , , Leave a comment

I executed the following command by mistake instead of “cd ..”

  • cd //

and strangely i was in some folder //
When I tried the command “pwd” i got the output as “//”.
When I tried the command “ls” i got the same output as if it was the “/” directory.
When I tried the command “cd ..” I was in the same directory as happens in “/” directory.
So I could conclude that it is the same “/” directory. But its existence did not make any sense then.

June 12, 2009

how to extract a .tar.bz2 file?

by viggy — Categories: Uncategorized — Tags: , , Leave a comment

@courtsey http://www.linuxforums.org/forum/linux-newbie/28238-how-can-i-extract-tar-bz2-file.html#post143394

bunzip2 .tar.bz2 which unzips to .tar

tar -tvf .tar (view contents in tar file)
tar -xvf .tar (extract contents in tar file)

June 10, 2009

How to add a man doc manually

by viggy — Categories: linux — Tags: , Leave a comment

you need to set the MANPATH variable to be able to access man pages which are not present in standard path. If for temporary purpose, you can just export MANPATH by the following command.
$export MANPATH=$MANPATH:/the/path/of/the/man/page/

Dont keep any space on either sides of “=” as it gives error as
“bash: export: `=’: not a valid identifier”.

To add permanently, you need to make changes in /etc/login.defs file. I am looking into it and will update this post as soon as i come to know of it