How to code a series of numbers in SH


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to code a series of numbers in SH
# 1  
Old 02-28-2010
How to code a series of numbers in SH

Hi.
How can I write this in a shorter way?

Code:
for NUMs in 1 2 3 4 5 6

I looked at the"seq" command, but I do not think that is what I want.

Can I code
Code:
for NUMs (1..7)

Hey!! Is that it?
# 2  
Old 02-28-2010
no, it's...

Code:
for NUMS in {1..5}

# 3  
Old 02-28-2010
Thank you protocomm. I appreciate your response.
Ccccc
# 4  
Old 02-28-2010
You can use the seq command(Not available in all *nix flavours)

Code:
for each in `seq 1 10 | xargs`
do
echo $each
done

# 5  
Old 03-01-2010
Thanks protocomm and hats off to you dennis j (dj).
Ccccc
# 6  
Old 03-01-2010
if you dont have seq, look for jot.
# 7  
Old 03-01-2010
Great. Will do glev2005.
What a Great Group. :-)
Ccccc
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Moving decimal point in a series of numbers

Hi, i need to move the decimal point from a file listing some numbers like this : 49899.50 49914.55 49894.48 49939.65 49879.44 49919.57 49934.62 49944.67 49954.72 (1 Reply)
Discussion started by: Board27
1 Replies

2. Shell Programming and Scripting

Help with Using "while" loop to output series of numbers

Trying to use "while" loop command to create a series of numbers that looks like the following: 0 . 1 0 . 2 1 0 . 3 2 1 0 . 4 3 2 1 0 . 5 4 3 2 1 0 . 6 5 4 3 2 1 0 . 7 6 5 4 3 2 1 0 . 8 7 6 5 4 3 2 1 0 . 9 8 7 6 5 4 3 2 1 0 . I am very new to shell scripting and any help would be... (7 Replies)
Discussion started by: tarlz
7 Replies

3. Shell Programming and Scripting

AWK series of numbers

Hi, I have a dataset say 1 2 3 4 5 5 6 7 6 7 8 9 I was wondering if there is a way to add another column with the following style... 1 2 3 4 xyz_1 5 5 6 7 xyz_2 6 7 8 9 xyz_3 It would be greatly appreciated if I can have an option of specifying what to write instead of xyz,... (8 Replies)
Discussion started by: jacobs.smith
8 Replies

4. UNIX for Dummies Questions & Answers

Have a list of numbers, want to write code to manipulate them

I have a list of numbers in the format: 5 4 15 65 32 I want to write code to manipulate the list and give me 100 - x such that the list looks like: 95 96 85 35 68 How do I go about doing that? Thanks! (9 Replies)
Discussion started by: evelibertine
9 Replies

5. UNIX for Dummies Questions & Answers

To find missing numbers from a number series

Hi, My requirement is I have an input file with a continuous series from 10000 to 99999. I have some numbers missing from those series. I want a output file which produces those missing numbers. Eg: 10002, 99999 are missing from the series then the output file should contain those... (4 Replies)
Discussion started by: rakeshbharadwaj
4 Replies

6. Homework & Coursework Questions

Help with shell script to find sum of first n numbers of Fibonacci series

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: Shell script to find sum of first n numbers of Fibonacci series 2. Relevant commands, code, scripts,... (0 Replies)
Discussion started by: Kshitija
0 Replies

7. Shell Programming and Scripting

How to sort out the latest one from a series of numbers?

Hi, I have a directory which contains a number of sub directories. They are named as 1.0.0, 1.0.1, 1.0.2...1.1.0..1.1.1...1.2.0..and so on.. Basically these are the tags created at the time of release. Tags are named as major.minor.buildnumber format for modules. Now I have to search the... (2 Replies)
Discussion started by: bhaskar_m
2 Replies

8. Shell Programming and Scripting

How to generate a series of numbers

Hi All, I have a requirement where in I have an input as follows:- input=1-4,6,8-10,12-15 I need to explode this range into an output file as follows:- 1 2 3 4 6 8 9 10 12 13 14 15 My input may vary like 1,5-9,11-13,15-17....... (3 Replies)
Discussion started by: rony_daniel
3 Replies
Login or Register to Ask a Question