-   Linux - Newbie (
-   -   WANTED HELP IN SCRIPT writing (

arsh gill 02-22-2012 11:07 AM

a script which will print "foo" when the input is "bar" and print "bar" when input is "foo"

anomie 02-22-2012 11:12 AM

If you'll be writing your script on a Linux system, bash would be a good candidate for your simple problem. I recommend taking the time to read:

If you run into problems, post what you've tried, and LQ members can offer suggestions.

grail 02-22-2012 12:00 PM

Show us your efforts and we will help.

salasi 02-22-2012 08:24 PM

There was another question, maybe a month or two back, that was very similar (it involved foo and bar, and a little extra complication...but then, so many questions seem to involve those two - foo and bar - that it isn't the easiest thing in the world to search on), so I wonder if maybe you and the other poster are at the same educational institution?

In any case, this being a program, you'll want to structure it, so you might want to start by posting the pseudocode you've come up with so far. You might not normally formally write pseudocode for a program this simple, but posting a flow chart would probably be a pain, and I'm not sure how else you'll be showing the rest of the world what you currently have in mind.

John VV 02-22-2012 09:05 PM


a script which will print "foo" when the input is "bar" and print "bar" when input is "foo"
WTF ?????

is there a question here?

from the other 3 posts this is homework
please BAN the user

colucix 02-23-2012 02:45 AM

Per the LQ Rules, please do not post homework assignments verbatim. We're happy to assist if you have specific questions or have hit a stumbling point, however. Let us know what you've already tried and what references you have used (including class notes, books, and Google searches) and we'll do our best to help. Also, keep in mind that your instructor might also be an LQ member.

cbtshare 02-23-2012 02:49 AM

yes its actually a question.It was asked in the forum already and answered.Look up variable substitution and you'll be on the right track..

David the H. 02-23-2012 11:59 AM

I'm not going to link to it at this time, but you're probably all thinking of the thread where I posted an unconventional solution to a very similar problem. ;) It wasn't foo and bar though, and the complication was that there was also a default value that needed to be printed if no input was given.

I don't think anyone ever actually posted a more conventional solution in that thread, but this is such a basic-level scripting problem that even a cursory reading of any scripting guide should be enough to solve it. :cool:

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