giovedì, settembre 10, 2009

String slicing in bash

Just a memo here:

${var_name:start_index:num_of_chars_after_index}

prompt:$ to_be_sliced="1234567890"

prompt:$ sliced=${to_be_sliced:5:${#to_be_sliced}}

prompt:$ echo $sliced
67890


Note:
${#var_name} returns the length of $var_name

martedì, settembre 08, 2009

RTFMP: Override resolv.conf from network manager

Hi,
a little post after so much time!

I always asked myself how I could override the search domain set by network manager or dhclient in /etc/resolv.conf but I never did it.

The easier and, I'd say, nicer solution comes from man /etc/resolv.conf! and it says:

"The search keyword of a system’s resolv.conf file can be overridden on a per-process basis by setting the environment variable LOCALDOMAIN to a space-separated list of search domains."

Not only it can be overriden! but also on a 'per process basis'!

Next time i have to remember to Read The Fucking Man Page.

Alleluja