Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

bash seq for loop not working on osx

I have a very simple loop (taken from http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-7.html):

#!/bin/bash
for i in `seq 1 10`;
do
echo $i
done

This works perfectly on Scientific linux (bash --version
GNU bash, version 3.2.25(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.)

But produces the following error on OSX 10.6.6:

~/scripts > ./test.sh
./test.sh: line 5: seq: command not found

~/scripts > bash --version
GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0)
Copyright (C) 2007 Free Software Foundation, Inc.
~/scripts >

Where is the seq command on OSX?

MacBook Pro, Mac OS X (10.6.6)

Posted on Mar 11, 2011 11:37 AM

Reply
Question marked as Best reply

Posted on Mar 11, 2011 12:11 PM

Mac OS X doesn't have the seq command available, so you'll have to use one of the other syntaxes for this construct. Here's an example:


for i in {1..10}
do
echo $i
done


Or maybe:

jot - 1 10


There's a version of a seq command [here|http://fredrik-rodland.blogspot.com/2008/10/seq-on-mac-os-x.html], if you have an installed base of "immutable" code that uses that syntax. Or have a look at the jot command, as shown above.
2 replies
Question marked as Best reply

Mar 11, 2011 12:11 PM in response to IvanGlushkov

Mac OS X doesn't have the seq command available, so you'll have to use one of the other syntaxes for this construct. Here's an example:


for i in {1..10}
do
echo $i
done


Or maybe:

jot - 1 10


There's a version of a seq command [here|http://fredrik-rodland.blogspot.com/2008/10/seq-on-mac-os-x.html], if you have an installed base of "immutable" code that uses that syntax. Or have a look at the jot command, as shown above.

bash seq for loop not working on osx

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.