PDA

View Full Version : Easy i'm Sure; not for me though :-(


kast
August 18th, 2007, 02:59 PM
Ok so I have Shell Programming book and at the end of every chapter there are exercises to help reinforce what you have learned up to that point.

So I usually pull my hair for a bit, but figure it out in the end, but I have one question for some reason I just get my head around!


"Write a program call suffix the renames a file by adding the characters given as the second argument to the end of the name of the file given as the first argument. So

$ ./suffix memo1 .sv

should rename memo1 to memo1.sv

so it would be Argument one = $1 and two $2 used in a little one-two lines script, that i can freaking get.

Thanks in advance!

cwaldbieser
August 18th, 2007, 03:03 PM
Ok so I have Shell Programming book and at the end of every chapter there are exercises to help reinforce what you have learned up to that point.

So I usually pull my hair for a bit, but figure it out in the end, but I have one question for some reason I just get my head around!


"Write a program call suffix the renames a file by adding the characters given as the second argument to the end of the name of the file given as the first argument. So

$ ./suffix memo1 .sv

should rename memo1 to memo1.sv

so it would be Argument one = $1 and two $2 used in a little one-two lines script, that i can freaking get.

Thanks in advance!
Does this give you an idea?

$ NAME=hello
$ SUFFIX=.txt
$ echo "$NAME$SUFFIX"

kast
August 18th, 2007, 03:56 PM
Thank you! that was exactly what i needed, i have been struggling on this, and of course its something simple as three lines.

thanks again!