Thanks, I don't know how I didn't spot the two sets. I've also got a working csh script with no space before the parenthesis.
I've changed the start of the file before the if because, as you can see from the output in the first post, the noFilesLocal and noFilesRemote variables are always going to be different as they include file paths. I've been trying to split them on the space character and use that to compare them but I'm having some difficulty with the syntax.
Code:
#!/bin/csh
echo 'Checking no of files in source and destination.'
set noFilesLocal = `ls | wc -l /`
echo $noFilesLocal
set noFilesRemote = `ls | wc -l /mnt/Backup/`
echo $noFilesRemote
set localArr = awk split($noFilesLocal,localArr, ' ')
echo $localArr
set noFilesLocal = $localArr[1]
echo $noFilesLocal
Which gives:
Quote:
Checking no of files in source and destination.
2 /
0 /mnt/Backup/
set: Syntax error
|
Update:
I found that cd'ing to the directory first instead of passing in the directory gives the number of items only without the file path being appended:
Code:
cd /
set noFilesLocal = `ls | wc -l`
echo $noFilesLocal
cd /mnt/Backup/
set noFilesRemote = `ls | wc -l`
echo $noFilesRemote