Search My Techie Guy

Wednesday, October 27, 2010

How to jump start a car?

Have you been in a situation where you forgot your car lamps on? And when you come back, the car battery is already drained to zero and your car won’t start.
All you need is a pair of jumper cables and a Good Samaritan driving by. Just follow the few steps below and your car will be up and running in less than 10 minutes.
o    Connect one red clamp to the positive (+) terminal of the dead battery.
o    Connect the other red clamp to the positive (+) terminal of the good battery.
o    Connect one black clamp to the negative (-) terminal of the good battery.
o    Connect the other black clamp to a piece of grounded metal on the dead car. Look for shiny metal (not painted or oily) that is attached to the engine. Usually a nut, bolt or other protruding shiny metal will work. You may see a small spark when you connect to a good ground. As a last resort, you may connect to the negative (-) post of the dead battery, but this risks igniting hydrogen gas coming off the battery.
o    Start the car with the good battery and keep the Engine running
o    Lastly, start the car with the dead battery and keep the Engine running.
o    You can now remove the jumper cables and drive on.

Monday, October 4, 2010

Text Manipulation with SED

SED in full is STREAM EDITOR - a UNIX utility used to manipulate text files.
It reads input files line by line (sequentially), applying the operation which has been specified via the command line (or a sed script), and then outputs the line.

In this post I present to you practical examples of SED. I have tried out these particular “one liners” and they have saved me a lot of time on several occasions.

As a Unix Admin, it’s important to understand SED because it will save you a lot of time when it comes to generating reports from a batch of text files, log analysis and data extraction from huge text files.

This list will keep growing with time as I get to use more of these “SED expressions”, so please feel free to track this post for any updates. Cheers and have FUN.

Extracting Numerical values from an Alphanumeric String
echo 123gvc4f5jy6 | sed 's#[^0-9]##g'

Joining a pair of lines side-by-side
cat my_file.txt | sed '$!N;s/\n/ /'

Search and replace a string marching a certain pattern
sed 's/bad/good/g' file_a.txt
The above command will search for "bad" and replace it with "good"

Insert a string at the begining of each line in a text file; e.g. insert "256"
cat my_file.txt |sed 's/^/256/' 

Append a character at the end of each line in a text file; e.g. append a semicolon (;)

cat my_file.txt |sed 's/$/;/'

To jump to a whole list of SED one liners, click on any of the links below:


http://sed.sourceforge.net/sed1line.txt
http://www.pement.org/sed/sed1line.txt