LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Please help me solve this code! (https://www.linuxquestions.org/questions/linux-newbie-8/please-help-me-solve-this-code-4175574831/)

LRob 03-14-2016 08:38 AM

Please help me solve this code!
 
echo "Hello World" | \
awk -F '' '{ for (i = NF; i > 0; --i) { printf("%s", $i) } }' | \
od -An -t uC | tr ' ' '\n' | sed '/^$/d'| \
awk 'BEGIN {
split("95:103:107:105:83:0:106:106:105:95:65:46", offset, ":")
i = 0
}
{
if ((i == 2) || (i == 8)) { print "." }
print $1 - offset[++i]
}' | \
sed 's/^32/ /' | tr -d '\n'

pan64 03-14-2016 09:45 AM

please use [code]here comes your script[/code]
These are a lot of commands, an echo, awk, od, tr, sed, awk, sed and tr.
You can analyze it command by command, so start with echo - that is a simple Hello World, next comes the awk:
Code:

$ echo "Hello World" | \
> awk -F '' '{ for (i = NF; i > 0; --i) { printf("%s", $i) } }'
dlroW olleH

Obviously this awk prints the same text - just in reverse order.
see man od, tr about their usage and flags

grail 03-14-2016 10:01 AM

As above, at least give it a go or be specific about which piece you do not understand.

LRob 03-14-2016 10:26 AM

I was hoping someone would just figure out what the output of this section of code would be. I'm not proficient at all, just wanted to get the answer to this puzzle.

Janus_Hyperion 03-14-2016 10:43 AM

Quote:

Originally Posted by LRob (Post 5515209)
I was hoping someone would just figure out what the output of this section of code would be. I'm not proficient at all, just wanted to get the answer to this puzzle.

If you run the code on the terminal, you would get the answer yourself. This would be an excellent opportunity to learn and become proficient ... No point in asking others to give you the answer.

ilesterg 03-14-2016 10:45 AM

Quote:

Originally Posted by LRob (Post 5515209)
I was hoping someone would just figure out what the output of this section of code would be. I'm not proficient at all, just wanted to get the answer to this puzzle.

That's not how the open source community works. People here are more than willing to help you solve your problems if only you don't sound like you're paying someone to do your job for you.

LRob 03-14-2016 10:51 AM

I apparently didn't make myself clear. This is not an assignment, it's not my job, it's simply a fun puzzle that should give coordinates to where a cache is hidden!
I'm not planning on becoming proficient and I don't have a terminal to run the code myself so I thought I would come to this forum for someone to get the answer!

pan64 03-14-2016 10:55 AM

the answer is: 55.764 52.367

ilesterg 03-14-2016 10:58 AM

Quote:

Originally Posted by LRob (Post 5515231)
I apparently didn't make myself clear. This is not an assignment, it's not my job, it's simply a fun puzzle that should give coordinates to where a cache is hidden!
I'm not planning on becoming proficient and I don't have a terminal to run the code myself so I thought I would come to this forum for someone to get the answer!

No worries. But where's the fun when you're going to ask somebody else figure out? Lol

LRob 03-14-2016 11:00 AM

Thank you Pan64. That looks to be where I was expecting the cache to be. I appreciate your time.

grail 03-14-2016 12:07 PM

Funny, I thought geocaching and the like was supposed to be about the thrill of finding the caches yourself. Apparently now you just get everyone else to do the work while you reap whatever
the prize / benefit might be ... I can see how this would be rewarding??

rtmistler 03-14-2016 12:30 PM

Quote:

Originally Posted by LRob (Post 5515231)
I apparently didn't make myself clear. This is not an assignment, it's not my job, it's simply a fun puzzle that should give coordinates to where a cache is hidden!
I'm not planning on becoming proficient and I don't have a terminal to run the code myself so I thought I would come to this forum for someone to get the answer!

No ... you made yourself VERY clear.

Suggestion is that you do not take on challenges in a form which require technology where you do not wish to learn or use it ever. Instead choose fun puzzles where you can solve them with your own resources. Why is it fun if you have absolutely no capability nor desire to attempt to solve it yourself? You apparently just want the end result. I'm sorry that someone decided to give you the result.

If you wish to continue using LQ, I'd suggestion reviewing http://www.linuxquestions.org/questi...#faq_lqwelcome

LRob 03-14-2016 12:37 PM

Wow, just relax, grail and rtmistler Your making lots of assumptions, aren't you? You're way off in what you're thinking.
Oh, and you might want to check your blood pressure if something like this makes you so upset.

rtmistler 03-14-2016 12:48 PM

Quote:

Originally Posted by LRob (Post 5515308)
Wow, just relax, grail and rtmistler Your making lots of assumptions, aren't you? You're way off in what you're thinking.
Oh, and you might want to check your blood pressure if something like this makes you so upset.

Oh please don't think we're sitting at terminals turning red faced about your complete inability to do anything Linux. I do hope that if you have future questions, you'll ask them in a manner which the forum typically prefers. But for all that, I yield to whatever the collective accepts. If instant reaction to "Help Me!" posts are the rage, then so be it.


All times are GMT -5. The time now is 03:26 AM.