0

Need your help. I've gone through the manual for the tch but still can't figure out how it should work in my case or whether it should work at all. I basically need to extract part of the variable whose value is a six digit number. So I need to drop the first two characters and
retrieve the last four. The example below doesn't work (it would probably work in bash but tcsh HAS to be used):

set VAR1 = value1

set VAR2 = echo ${VAR1:2}

echo VAR2

It comes up with error "Bad : modifier in $ (2)". Apparently, that's coz its bash syntax and not understandable by tcsh, but can't figure out how to do it with tcsh arguments.

0

that is bash syntax you are using, for tcsh it should be

$VAR1:s/1/2/
  • Thanks, but it's not exactly what I need. This way it just replaces all 1's with 2's regardless of their position within the variable. But I need to replace the first two characters regardless of their value. I need the offset, not the value. – Dmitry Erin Sep 5 '14 at 18:04

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.