Sponsored Content
Top Forums Shell Programming and Scripting Range specification in for loop Post 302136836 by Yogesh Sawant on Thursday 20th of September 2007 01:40:03 AM
Old 09-20-2007
Your shell does not have the .. range operator. Try this instead:
Code:
#!/bin/bash
LIMIT=24
for ((a=1; a <= LIMIT ; a++))  # Double parentheses, and "LIMIT" with no "$".
do
  echo -n "$a "
done                           # A construct borrowed from 'ksh93'.
echo; echo

or this:
Code:
#!/bin/bash
NUMBERS="1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24"
for number in `echo $NUMBERS`  # would be similar to: for number in 1 .. 24
do
  echo -n "$number "
done
echo

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

HD specification

What command do I use to determine how many/what kind/how big the hard drives on a box are? (2 Replies)
Discussion started by: abolshoun
2 Replies

2. Solaris

hardware specification ( very Urgent please )

I wana know my box hardware specification ( Like RAM , processor speed .... Etc ) and used version of Solaris i mean (SPARC, 32-bit) or (x86, 32-bit) or(SPARC, 64-bit) or what ?? very Urgent please (5 Replies)
Discussion started by: KSA
5 Replies

3. Solaris

System specification checking

Hi, anybody know how to check the system specification for the unix by using the command like the memory size, cpu's speed and etc. Thanks. (3 Replies)
Discussion started by: efang
3 Replies

4. UNIX for Dummies Questions & Answers

RSC card specification

Hi I have a SUN box that i am supporting Model 480r . The RS card that is attached to it is giving some problems . It is pinging but i am unable to telnet into it therefore having no remote TC console access ( the system is currently up ) Is there a way by which i can remotely check the... (1 Reply)
Discussion started by: Sam4u
1 Replies

5. Solaris

Getting server specification

Hi all, Can anyone help me to get the server specifications like the following? eg. SUN Fire XXX X UltraSPARC X MHZ X MB Memory X GB od hard disk X On board PCI IO card X PCI HNI card Thanks. (4 Replies)
Discussion started by: beginningDBA
4 Replies

6. Shell Programming and Scripting

For Loop Range Create Directories

Hello, I am a bit stumped on this. I am attempting to create 24 empty directories with a loop. Seems like I have incorrect syntax. When I run the following command I get the error below. Command $ for i in {2..24}; do mkdir $i_MAY_2011 ; doneError x 24 mkdir: missing operand Try `mkdir... (2 Replies)
Discussion started by: jaysunn
2 Replies

7. Shell Programming and Scripting

loop directories mv files to target in range

Hello, Currently I have a painstaking process that I use to move file for a monthly archive. I have to run the same two commands for 24 different directories. I wish to have a script with a for loop automate this and I have not been able to succeed. Here is what I do 24 times. I know this is... (5 Replies)
Discussion started by: jaysunn
5 Replies

8. Shell Programming and Scripting

use variable to set the range of a for loop

Hi; For sure there's an easy answer to this one that I am not finding.. I first set a variable, say b1a:] max=5 then I want to use max to set the range for a for loop like so (it should run for i in 1:5) b1a:] for i in {1..$max}; do echo $i; done {1..5} I would like the output... (2 Replies)
Discussion started by: jbr950
2 Replies

9. Shell Programming and Scripting

Help with column specification

Hi I am working on a program that reads a file with multiple columns and was curious how to specify the columns to be manipulated in the command line. For example the file may look something like: Column1 Column2 Column3 Column4 Column5 Column6 AC 82542 3525 ... (1 Reply)
Discussion started by: drossy
1 Replies

10. Homework & Coursework Questions

Bash Script for Dice Game; Issue with if...else loop to verify user guess is within range

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I have written a script for a dice game that: (1) tells user that each of the 2 die are 6 sided (Spots=6); (2)... (3 Replies)
Discussion started by: LaurenRose
3 Replies
COMMAND-NOT-FOUND(1)					    http://en.opensuse.org/Sco					      COMMAND-NOT-FOUND(1)

NAME
command-not-found - A command-not-found handler SYNOPSIS
command-not-found {binary_name} {repository} ARGUMENTS
The following arguments are required: binary_name The name of binary you are looking for. repository The name of repository for search. For most cases, use zypp DESCRIPTION
command-not-found handler is designed to tell users which package contains a missing command. The handler is integrated to bash(1) and zsh(1) shells and is not necessary to call it directly. Just type a name of the command in your favourite shell and you'll get a result. If you consider c-n-f handler useless, just add unset command_not_found_handle to your profile or remove the command-not-found package. Handler doesn't call the command-not-found binary directly, it only prints info about it. If you want to invoke it automatically, just add export COMMAND_NOT_FOUND_AUTO=1 to your bash profile. EXAMPLE
: NORMAL USAGE For example you want to try blender, because you have heard that is an amazing program. So just type blender in shell: $ blender You get the following output: The program 'blender' can be found in the following package: * blender [ path: /usr/bin/blender, repository: zypp (openSUSE 11.1-0) ] Try installing with: sudo zypper install blender bash: blender: command not found SEE ALSO
scout(1) AUTHOR
Pavol Rusnak <stick@gk2.sk> Developer http://gitorious.org/opensus 08/07/2009 COMMAND-NOT-FOUND(1)
All times are GMT -4. The time now is 01:39 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy