Printable Version of Topic

Click here to view this topic in its original format

Linuxhelp _ Programming in Linux _ Bourne Shell Scipts

Posted by: philmetz Oct 1 2008, 04:22 AM

I am trying to create a bourne shell script that will simply copy a file given command line arguments (first = file to copy, 2nd = name of second copy)

How can say copy a file?
I thought I could try:
echo "File 1 is" $file1
echo "File 2 is" $file2

cp file1 file2

but doesnt work

Posted by: philmetz Oct 1 2008, 04:38 AM

Ok i fixed it, forgot to add $
But got a new problem, is there a relationship operator in sh like AND(&&)?
I am trying the following:
if [ $# = 2 && -e $file1]
echo "File 1 is" $file1
echo "File 2 is" $file2
cp $file1 $file2
echo "ERROR: Not enough command line arguments OR file does not exists!"

So is there a way i can use &&

Posted by: michaelk Oct 2 2008, 11:36 AM

Here you go.

Powered by Invision Power Board (
© Invision Power Services (