The Seq__linux of Linux common commands

Source: Internet
Author: User


The SEQ command is used to print numbers to the mantissa starting with the specified increment, that is, to produce all integers from one number to another, and to control the format, width, and split symbol of an integer.


Grammar:

[1] seq [option] Mantissa

[2] SEQ [options] The mantissa of the first number

[3] SEQ [option] The first increment of the mantissa


Options:

-F,--format= format using printf-style floating-point format

-S, the--separator= string separates numbers using the specified string (by default: \ n)

-W,--equal-width add 0 before column to make the same width


Ex1, Syntax examples

[Zhangqi@localhost shellscript]$ seq 5
1
2
3
4
5
[zhangqi@localhost shellscript]$ seq 1 5
1
2
3
4
5
[zhangqi@localhost shellscript]$ seq 1
2 5 1 3 5 [ Zhangqi@localhost shellscript]$ 

As you can see from the example above, when the first number of SEQ is empty, the default is 1


EX2, F option Example

[Zhangqi@localhost shellscript]$ seq-f "%2g" 9/
 9
[zhangqi@localhost shellscript]$ seq-f "%3g" 9
  (9
 )
[zhangqi@localhost shellscript]$ seq-f "%03g" 9
/009 010 011 [ Zhangqi@localhost shellscript]$ seq-f "str%03g" 9
str009 str010
str011

The example above shows the number of digits after%, the default is%g,%3g so that the number of digits is not enough is a space, the symbol before the number represents the padding bit.


EX3, S option sample

[Zhangqi@localhost shellscript]$ Seq-s ":" F "str%03g" 9
str009:str010:str011

Between the characters of the output ":" Interval


EX4, W option example

[Zhangqi@localhost shellscript]$ seq-w 9
[zhangqi@localhost shellscript]$ seq-f "%2g"-W 9 1 1
Seq:format string May is specified when printing equal the width strings
Try ' seq--help ' for more information.
[Zhangqi@localhost shellscript]$ 

As you can see from the example above, the numbers for the W option output are equal widths, and W and F cannot be used at the same time.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.