Monday, December 27, 2010

Using sed to delete line with text containing file path

Hi

It took me a day to figure out, how can i delete a line in file using sed. This was pretty simple.

#sed 's/your_string//g'

Now if your string is in a variable than you are going to use is.


#sed 's/$var//g'

**Now problem was your variable contains a path of a file 'say /etc/passwd '
It really doesn't works simply. because of '/' constraints. 

I figured it out to be worked as....

sed -i "\#$i#d" $infile

This way value in variable $i will be deleted from file "$infile" 
This is not very easily available on net.




Some more sed important examples...
-> To delete blank line from a text file.
sed '/^$/d'

This is to remove all spaces from the file.

sed 's/ //g'

Sunday, December 5, 2010

Nayak Movie Anil Kapoor

Today i was watching Nayak Movie on one of the TV Channel one of my favorite movie. This is one movie shown again and again on TV, I am sure that people like to watch this movie.

People like to watch movie which show their dreams on screen. We badly want to see same thing happening in real life. We are waiting for a hero like Anil Kapoor to stand up and lead us to a bright future including me.

How do you feel when Anil Kapoor suspends all corrupt officers, how you feel when you see him talking to delegations for implementing new projects. :)

will continue .........busy watching Peepli Live right now ..