[SOLVED] What is the easiest way to convert this hash format to another format?
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
What is the easiest way to convert this hash format to another format?
Could you help me what the easiest way is to convert these hashes on terminal with commands?
From this format:
to his format:
You're welcome. The important thing is that "awk" becomes more familiar. It will over time. What did you think of the "awk" manual page regarding FS and OFS? And about $1 and $2 and how they relate to FS and OFS?
Thanks. I like awk. FS= file separator of input data, OFS= file separator of output data, changing FS to OFS. Is it correct?
I got another tip:
sed -n "s/\(.*\),\([a-f0-9]*\)/\2:\1/p" input.txt >> output.txt
What is the difference between awk and sed?
I know tr, uniq, sort, cat, tac and other easy commands. awk and sed more complex....But until this time I didn't need these commands. So which is the most familar? Which is easier to learn?
They each lend themselves to somewhat different tasks. It's useful to find what you find each is good for and then use them for that. There is often an optimal zone where a task will lend itself more to one than another. So it's more of the idea of the right tool for the job. As to what is more familiar, that depends on which one you use most. For me it is "perl". You should find all three on any system you encounter. They're all pretty easy to get the hang of, again the one you use most will become most familiar and thus easiest.
One thing to remember is maintainability and much of that depends on code that clear to understand. You can do weird or overly clever things in "sed" that might be easier for another person to follow if you use "awk". Same for "perl" over "awk". But anyone can write clear or unclear code in most any language, since a good portion of that choice is up to the coder. Make the computer do the work. That's what it's for.