cancel
Showing results for 
Search instead for 
Did you mean: 
Trevor
Commander Commander
Commander
  • 96 Views

seq Command

The seq command prints a sequence (range) of numbers, based on some incrementing value.  

$ seq  0 1 10
- prints a range (sequence) of numbers from 0 to 10, incrementing by 1

$ seq 1 2 18
- prints a range (sequence) of numbers from 1 to 18, incrementing by 2

$ seq 2 3 30
- prints a range (sequence) of numbers from 2 to 30, incrementing by 3

 

Is there another "single" command that can perform the same task?

Thanks in advance!

Trevor "Red Hat Evangelist" Chandler
Labels (3)
2 Replies
Ad_astra
Flight Engineer Flight Engineer
Flight Engineer
  • 65 Views

Hi

An alternative to the seq command would be the printf command. As follows:

printf "%s\n" {0..10}

printf "%s\n" {1..18..2}

printf "%s\n" {2..30..3}

This will produce the same results as the seq commands.

The difference here is that you have to specify both the format of the output and the incremental vaue is last in the list of parameters! 

Regards

AA

0 Kudos
Chetan_Tiwary_
Community Manager
Community Manager
  • 35 Views

@Trevor 

Chetan_Tiwary__0-1765202724597.png

 

Join the discussion
You must log in to join this conversation.