1

Can anyone tell me what I am doing wrong ?

[ /jlr/sub/libexec/vmr-staging ] $ expr substr "onetwothree" 1 4
expr: syntax error

I got the syntax from https://stackoverflow.com/a/220464/1150847

3
  • which OS du you use? substr is a non standard extention. The came be achieved with cut: echo "onetwothree" | cut -c 1-3
    – kofemann
    Apr 20, 2013 at 19:39
  • I am developing in OS X, Production is CentOS, cut worked! Please post it as an answer and I will check it off =] Apr 20, 2013 at 20:37
  • Id love to know why this was down voted Apr 22, 2013 at 17:43

1 Answer 1

2

The substr operation is a non standard extension and not supported on all OSes (probably linux only). The same be achieved with cut:

echo "onetwothree" | cut -c 1-3

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .