philmetz
10-01-2008, 10:45 AM
Hi can someone tell me whats wrong with the following script i made:
#!/bin/sh
file1=$1
file2=$2
if [ $# = 2 && -e $file1]
then
if [ -e $file1 ]
then
echo "File 1 is" $file1
echo "File 2 is" $file2
cp $file1 $file2
else
echo "ERROR: File does not exist!"
fi
else
echo "ERROR: Not enough command line arguments!"
fi
The problem is:
philip@philip-laptop:~/Desktop$ sh copy.sh test.java test2.java
[: 16: missing ]
ERROR: Not enough command line arguments!
#!/bin/sh
file1=$1
file2=$2
if [ $# = 2 && -e $file1]
then
if [ -e $file1 ]
then
echo "File 1 is" $file1
echo "File 2 is" $file2
cp $file1 $file2
else
echo "ERROR: File does not exist!"
fi
else
echo "ERROR: Not enough command line arguments!"
fi
The problem is:
philip@philip-laptop:~/Desktop$ sh copy.sh test.java test2.java
[: 16: missing ]
ERROR: Not enough command line arguments!