Help - Search - Members - Calendar
Full Version: Noob needs help with script
Linuxhelp > Support > Programming in Linux
Yaesu
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
michaelk
I assume this is homework. Have you tried searching the web for help with bash programming?

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

This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2017 Invision Power Services, Inc.