Link to home
Start Free TrialLog in
Avatar of Pranesh
PraneshFlag for Australia

asked on

Bash script

Good day Group

I am just a beginner with bash scripting and I just need some direction in creating a script. So basically, I need to create a script where if
I execute with the script like this :

./script bob - it prints out Mary

and

./script Mary - it prints out bob

and if neither command is parsed to it, it returns to stand err

Any suggestions would be highly appreciated.
ASKER CERTIFIED SOLUTION
Avatar of omarfarid
omarfarid
Flag of United Arab Emirates image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of egarciat
egarciat

as a complement to omarfarid's post, I would change the following:

*)
      echo wrong name

to:

*)
      echo "wrong name" >&2

That will write "wrong name" to standard error..

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
unless other wise provided for 2>&1 and >&2 are exactly the same.  typicall stderr is redirected to a file for debugging.  stderr defaults to stdout unless outerwise directed.  since tuxracer did not specify a file both 2>&1 and >&2 are exactly the same.
Avatar of Pranesh

ASKER

Hi Guys

Thank you all for the great responses. Its what I was looking for for.

Much appreciated!!!! Collaboration - rocks!!!

Tuxracer
Welcome