Showing posts with label echo (command). Show all posts
Showing posts with label echo (command). Show all posts

Wednesday, September 7, 2016

Emoji: Converting from and to UTF-8 Hexadecimal

Command:

$ echo -e "\xF0\x9F\x98\x80"


Result:

😀


Command:

$ echo -n 😀 | hexdump


Result:

0000000 f0 9f 98 80                                  
0000004


Tuesday, February 2, 2016

AWK: Calling Bash Version of echo Command with \c Option

I don't know how to embed Bourne shell echo with \c option inside AWK script, so I did this way.

echo.bash

#!/bin/bash
for i; do
echo -n $i
done


AWK script using above echo.bash script, so you can call bash version of echo:

$ awk -F, '{
cmd="./echo.bash \""$2"\" | openssl dgst -sha256"
while (cmd | getline line){
print line
}
close(cmd)
}' ./test.txt

Monday, February 1, 2016

The Difference Between Bash and Bourne Shell When Using echo Command

Bash

$ echo -n "A. P. Balachandran" | md5
b9114dc37ab93677d533a0e3e025ee58

Bourne shell: Same value!

sh-3.2$ echo "A. P. Balachandran\c" | md5
b9114dc37ab93677d533a0e3e025ee58

Bourne shell: wrong md5 value!

sh-3.2$ echo -n "A. P. Balachandran" | md5
9e63b57c592863eaad63d37f72bce0d0

Bourne shell: -n option isn't working. That is why.

sh-3.2$ echo -n "A. P. Balachandran"
-n A. P. Balachandran