Bash: read file with ignoring new line

Usually i always read file in bash by iterating through for loop like following

 
for line in `cat /path/to/file`;do
   echo "Processing => $line"
done

but sometime the file that i need to open has special character that make mess every line in file that i read, for example if i open with command line editor such as vim the words within line looks line a normal one:
Hello this is a normal line
but when i use the normal for loop it will be like this

Hello
this
is
a
normal
line

After searching in google i found the solution in stackoverflow by using read command and the file the will be opened as stdin:

MACLIST='/etc/ethers'

DONE=false
until $DONE ;do
        read || DONE=true
        # ignore every thing that begin with shebang
        echo $REPLY | grep '^#' > /dev/null && continue

        MACADDR=`echo $REPLY | awk '{print $1}'`
        IPADDR=`echo $REPLY | awk '{print $2}'`

        # if there is no macaddr or ipaddr then ignore it
        if [ -z $MACADDR ] || [ -z $IPADDR ];then
                continue
        fi

        echo "$MACADDR => $IPADDR"
done < $MACLIST

The variable REPLY contains current line of loop process.

Decode Url Parameter

When i tracing some ajax activity from an apps that connected to Alfresco API like this

192.168.113.44%3A8080%2Falfresco%2Fservice%2Fapi%2Flogin%3Fu%3Domar%26pw%3Dkacangitem

Event though it still readable but sometime the url are more longer with ticket ID, i can encode the url with online tools such as this one but my friend told me it can be done with python.

from urllib import unqoute

target = &amp;quot;192.168.113.44%3A8080%2Falfresco%2Fservice%2Fapi%2Flogin%3Fu%3Domar%26pw%3Dkacangitem&amp;quot;
print unqoute(target)

Selamat datang agustus

Wahh udah lama banget tidak menyentuh dunia blog, terkahir masih rajin nulis blog kira-kira 4 tahun yang lalu (2010). semoga di blog baru ini bisa istiqomah untuk di-update terus :).

 

By the way pada bulan ini kebanjiran hal-hal baru yang akan di oprek seperti ansible untuk mempermudah dalam manage belasan server (Linux based), Membuat plugin sosreport dan master-master mysql replication menggunakan galera. InsyaAllah dokumentasinya saya posting diblog ini. Ganbateeee 😀