Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I need help with writing this shell script. Could someone please help me. Thanks.

Write a shell script my_echo that accepts an arbitrary number of arguments and prints them, one per line, adding text "(this is an integer)" after each argument, which is an integer.

share|improve this question
3  
Sounds like a homework –  sputnick Feb 22 '13 at 13:15
5  
what have you tried? –  mcalex Feb 22 '13 at 13:30

1 Answer 1

use this

save this to my_echo.sh

#!/usr/bin/env bash
a=$1
b=$2
c=$3
text=10
a=$[$a + $text]
b=$[$b + $text]
c=$[$c + $text]
echo "$a"
echo "$b"
echo "$c"

then chmod 777 my_echo.sh

then run ./my_echo.sh 2 4 6

share|improve this answer
    
No No no NO! chmod 777 is NEVER acceptable. –  Hennes Dec 23 '13 at 15:31
    
Apart from that, this doesn't do what the OP needs –  slhck Dec 23 '13 at 15:36
    
I did not even check that after I saw the failed #, the direct path to a potential bash location and the code which seemed very inflexible. I would expect something with shift registers. –  Hennes Dec 23 '13 at 17:49
    
Then give chmod u+x because you only run the program. Or try simply as sh my_echo.sh 2 4 6 –  mailer Dec 24 '13 at 2:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.