Printable Version of Topic

Click here to view this topic in its original format

Linuxhelp _ Programming in Linux _ Noob needs help with script

Posted by: Yaesu Apr 25 2013, 09:21 PM

I need to create a script that will check to see if a file exists and if it does then make 10 copies of itself with an appended name in another directory. This is what I have but its not working. I got the error message to work but I cant even get it to make one copy of itself. if i use a known file it still gives me an error message that I created. Can someone check this out for me.

CODE
#!/bin/sh

if [ $1 -e ]
     then
         N=1
         while [$N -le 10 ]
     do
         cp $1 $2
     done
          
     else
         echo File does not exist.
     fi

Posted by: michaelk Apr 27 2013, 08:56 AM

I assume this is homework. Have you tried searching the web for help with bash programming?

/www.cyberciti.biz/faq/bash-while-loop/


Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)