[20130416]seq命令.txt

lfree發表於2013-04-16
[20130416]seq命令.txt

昨天看一些shell指令碼,發現一個命令seq。自己以前從來沒有使用過。

$ rpm -qif `which seq`
Name        : coreutils                    Relocations: (not relocatable)
Version     : 5.2.1                             Vendor: Red Hat, Inc.
Release     : 31.2                          Build Date: Mon 20 Jun 2005 07:45:58 PM CST Install Date: Fri 06 Jul 2007
Install Date: Fri 06 Jul 2007 03:30:09 PM CST      Build Host: crowe.devel.redhat.com
Group       : System Environment/Base       Source RPM: coreutils-5.2.1-31.2.src.rpm
Size        : 7636028                          License: GPL
Signature   : DSA/SHA1, Thu 14 Jul 2005 02:52:44 AM CST, Key ID 219180cddb42a60e
Packager    : Red Hat, Inc. <
URL         : ftp://alpha.gnu.org/gnu/coreutils/
Summary     : The GNU core utilities: a set of tools commonly used in shell scripts
Description :
These are the GNU core utilities.  This package is the combination of
the old GNU fileutils, sh-utils, and textutils packages.


$ man seq
SEQ(1)                                                                                        User Commands

NAME
       seq - print a sequence of numbers

SYNOPSIS
       seq [OPTION]... LAST
       seq [OPTION]... FIRST LAST
       seq [OPTION]... FIRST INCREMENT LAST

DESCRIPTION
       Print numbers from FIRST to LAST, in steps of INCREMENT.

       -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

       --help display this help and exit

       --version
              output version information and exit

        If  FIRST  or  INCREMENT is omitted, it defaults to 1.  That is, an omitted INCREMENT defaults to 1 even when LAST
is smaller than FIRST.  FIRST, INCREMENT, and LAST are interpreted as floating point values.  INCREMENT is usually
positive if FIRST is smaller than LAST, and INCREMENT is usually negative if FIRST is greater than LAST.   When  given,
the FORMAT  argument  must  contain exactly one of the printf-style, floating point output formats %e, %f, %g


$ cat conn.sql
#! /bin/bash
for ((i=1; ido
 sqlplus scott/xxxx @aa.sql &
done

--這樣那個可以寫成

for i in $(seq 10); do
 sqlplus scott/xxxx @aa.sql &
done

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-758573/,如需轉載,請註明出處,否則將追究法律責任。

相關文章