Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
#!/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 a newbie to shell scripts. 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.

share|improve this question
    
Try endif instead of fi? I'm a beginner too. Make sure you check this amazing document. – のbるしtyぱんky 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

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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