2
#!/bin/csh -f

set no=1460
while ("$no">0)
if [$no>900]; then
 set m=3
else if ["$no">450 && "$no"<901]; then
 set  m=2
else
 set m=1
fi
mv *$no.bin test/abc-$m-$no.bin
set no =$no-1
end

I'm trying to rename 1460 files using a csh script, but I get a syntax error "syntax error: unexpected end of file" I'm on tcsh shell.
I've tried both fi and end to end the if condition. I get the same error.

  • Try endif instead of fi? I'm a beginner too. Make sure you check this amazing document. – user44370 May 26 '14 at 8:20
  • 3
    There's no point whatsoever trying to learn csh in this millennium. Your system, if it is less than 20 years old will have a POSIX shell, at least a Bourne-like shell if it's less than 30 years old. Use that instead. – Stéphane Chazelas May 26 '14 at 8:54
1

A quick Google search reveals that your IF statement syntax is probably incorrect. You may be mixing syntax from another shell.

if ( $no > 900 ) then
  set m=3
else if ( $no > 450 && $no < 901)
  set m=2
else
  set m=1
endif

http://beefchunk.com/documentation/tips/unix_tips_and_tricks/node40.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.