Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Generate sequence of numbers 1

Status
Not open for further replies.

tivona

Technical User
Oct 23, 2010
6
HK
Dear all,

I would like you have your advice on how to generate the following pattern of sequence numbers using awk.

Input

2
4
3

Output

2
1
4
3
2
1
3
2
1

Thanks in advance

Tivona



 
Typed, untested:
Code:
awk '{for(i=$1;i>0;--i}print i}' /path/to/input

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Dear PH,

It works great except for a missing ")".
awk '{for(i=$1;i>0;--i) print i}' /path/to/input

Cheers,

Tivona

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top