Usage of the SEQ command in Linux

Source: Internet
Author: User

Used to generate all integers from one number to another
Example one:
# seq 1 10
The result is 1 2 3 4 5 6 7 8 9 10
Example two:
#!/bin/bash
For i in ' seq 1 10 ';
Do
echo $i;
Done
or with
For I in $ (SEQ 1 10)
can also seq
-F,--format=format use printf style floating-point format (default:%G)
-S,--separator=string use STRING to separate numbers (default:/N)
-W,--equal-width equalize width by padding with leading zeroes

- FOptions Specify format
#seq-F "%3g" 9 11
9
10
11
% the number of digits specified after the default is "%g",
"%3G" then the number of digits is not enough space
#sed-F "%03g" 9 11 so the number of digits is less than 0.
% before the string is drawn
Seq-f "STR%03G" 9 11
str009
str010
str011

- WSpecifies that the output number is equal to the width cannot be used with-f
Seq-w-F "str%03g" 9 11
Seq:format string May is specified when printing equal width strings
SEQ-W 98 101
098
099
100
101
The output is the same width

- SSpecifies that the delimiter is carriage return by default
Seq-s ""-F "str%03g" 9 11
str009 str010 str011
To specify/t as the separator symbol
Seq-s "' Echo-e"/t "'" 9 11

Specify/n/n as the separator symbol
Seq-s "' Echo-e"/n/n "'" 9 11
19293949596979899910911
Got a bad result.
But it doesn't have to be that way. The default is enter as the delimiter

Usage of the SEQ command in Linux

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.