|
OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below. |
|
Thread Tools | Display Modes |
|
|||
Script: how translate for i in `seq $1 $2`?
How translate the bash command:
for i in `seq $1 $2` on: $ echo $SHELL /bin/ksh ? Essentially i would like pass two argument on for instead to put two fix number all the time. Now i have problem with seq (bash). |
|
|||
man jot
|
|
|||
Thanks.
Code:
#!/bin/sh for i in `jot - $2 $3 1` do echo $i done Last edited by aleunix; 11th March 2012 at 04:18 PM. |
|
||||
Glad the problem is solved with jot. Just to clarify ...
Is seq really a bash command now? I don't find it mentioned in the bash man pages I looked at (though they're not the very latest). Both NetBSD and some Linux distributions have a stand-alone seq(1) command. And bash has a construct (in newer versions anyway) % echo {1..10} 1 2 3 4 5 6 7 8 9 10 which does a similar thing (in simple cases). |
|
|||
Now i'm on OpenBSD so i don't check it but i think you have right.
Now i was thinking at something sufficient general for avoid to use seq or jot that can be work on OpenBSD and Linux without modification of the code. These attempt failed: Quote:
i=$1 while [ "$i" -le $2 ] do echo $i let "i+=1" done I haven't check on Linux but given that i make this change while see it: Example 11-17. C-style syntax in a while loop from the Advanced Bash-Scripting Guide i suppose that should work. |
Tags |
bash, command for, ksh, script, shell |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
NAT64: OpenBSD 5.1 will translate between IPv4 and IPv6 | J65nko | News | 0 | 27th February 2012 10:37 PM |
Crontab won't run script | Petrocelli08 | FreeBSD General | 4 | 7th March 2009 04:19 AM |
Handy X11 script | Gabe_G23 | Guides | 6 | 25th October 2008 05:08 PM |
my 1st sh script | graudeejs | Programming | 12 | 18th August 2008 10:25 PM |
Shell Script. | bsdnewbie999 | Programming | 21 | 15th July 2008 07:54 AM |