Using awk to replace a block on a text file

Hello people,
If you need to replace a text block on a file you may use awk with the following sintax:
awk ‘/start/{f=1;print;while (getline < “replace.txt”){print}}/end/{f=0}!f’ datafile.txt

where datafile.txt:

bla bla bla
<start>
ble ble ble
ble ble ble
<end>
blo blo

and replace.txt like:

TEST OK

the outcome should be:

bla bla bla
<start>
TEST OK
<end>
blo blo

Cheers,
Pedro Oliveira

Using cat,ssh and dd to copy ISOs

Hi!
After a long time without posting on the blog here I come again with a tiny command line that can speed up the usual method of copying large amounts of data.

Sometime ago a college gave me a DVD that I would like to keep to myself but that other 2 colleges wanted too. I used dd, cat and ssh for the task. Taking less that 5 minutes to do it all.

First I started the .iso creation with dd:

dd if=/dev/cdrom of=/home/pedro/my_new_iso.iso

In other console you may start the copy of the iso file even if the iso it’s fully copied to the hard drive (just give a few seconds to have some data copied to the drive):

(cat /home/pedro/my_new_iso.iso | ssh user@remote.host.local dd of=~/my_new_iso.iso) ; (cat /home/pedro/my_new_iso.iso | ssh user2@remote2.host.local dd of=~/my_new_iso.iso)

The only thing you need to guarantee is that the first command ends before the second one.
Cheers,
See you all next time

Story of a geek

Today I was talking to a work mate about our childhood and that brought me a lot of memories, I’ll share a few with you guys…

In the 80’s I was only a child but I had an holder brother who was an electronics geek. More I grew up in the middle of music, beta max and VHS tapes, Spectrums (from the 48K till the 128K), then the Atari, and the firsts Nintendos (that weren’t available here and a friend bought in the states and gave it to me), electric cables, transistors, oscilloscopes and so on… this till I was about 10 more or less.

Then it came the Amiga 500 (with the unique multi process capability at the time, 4096 colour display that was a fabulous display, 8 bit sound, etc, etc), dam I used to love that little machine connected to my tv. But the real thing was when my parents bought me a modem it was a US Robotics modem capable of reaching 9600Band that was the time of BBS, black boxes, blue boxes…

Check the Amiga 500 Capabilities…

httpv://www.youtube.com/watch?v=DaRkacQ-YMg

After that came the turbulent teenage times and computer and tech moved a bit to the side way, but only to come back very strong around 95 with the mass usage of Internet and Internet dating.

After that it came the IBM compatible PC (after updating my Amiga 500 to the A600 and then to the A2000), the first one it was a P100 witch i recall my friends complaining that the 32 MB RAM were a waste and never in my live i would fully use it… guess who got it right.

From then till now i don’t know how many systems I’ve owned and manage at work, probably hundreds or even thousands.

For the people who read this you may think that I didn’t do much more than computers in my live but it’s not like that, since I was a kid I always wanted to be a scientist or teacher, so the first university year I studied Biology even got a scholarship but in the end I didn’t enjoy the lab has i thought I would and moved to Computers. I still love chemistry, physics, and biology but nevertheless I like computers better.

IT gave a nice live till now, took me to far away countries to work, managed to work in large and small companies, did some huge projects and other just for fun. The best of all made make a lot of friends and open my mind about different ways of working, different ways of seeing life and what surround us. In the end while working abroad I knew a girl who latter on became my wife…

Well hope this little story may bring your stories about those times, if you wish leave a comment.

Cheers,
Pedro

Who’s Pedro Oliveira

Pedro Oliveira

My name is Pedro Oliveira, I’m a Linux fan and enthusiast for the last 18 years. Apart from that I’m a System Architect / Technical manager.

I’ve done projects in several countries (Portugal, USA, Mexico, UK, Spain, Angola, Netherlands, etc). I’ve also been blessed to live for extended periods in some of them.

With this blog I expect to share some of my experiences while working in heterogeneous environments (MS, Linux, Solaris, etc) and some other skills and visions I have on different matters.

This may include thoughts about football, hobbies (like radio controlled stuff).

If you want to check a bit more about me and the projects I’ve work please check my linkedin  profile or follow me on twitter: @X_MartiniMan_X

Have fun, as SuSE guys say…

Pedro Oliveira