Convert ascii string to hex

echo -n "text" | od -A n -t x1 |sed 's/ /\\x/g'
If you're going to use od, here's how to suppress the labels at the beginning. Also, it doesn't output the \x, hence the sed command at the end. Remove it for space separated hex values instead
Sample Output
\x74\x65\x78\x74

5
2010-07-14 15:31:36

6 Alternatives + Submit Alt

What Others Think

I had to forge some new hostid for Solaris stations and this command was very useful. Thanks
Sigfrodi · 484 weeks and 6 days ago
This website is only a guide for users to understand the process to Download, Install and Activate Webroot Products, We do not have any affiliations from Webroot Login and any other company related to Antivirus.Antivirus is essential software that helps in removing internet viruses and threats. But how many people use them? Internet security is a sizable concern in the 21st century. But people still choose to ignore the power of hackers and what they can do with the technology they had. It’s important to update yourself about internet security from time-to-time.
johnmartin0366 · 13 weeks and 2 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: