fbpx
Wikipedia

seq (Unix)

On Unix-like computer systems, seq is a utility for generating a sequence of numbers.

History edit

seq first appeared on 8th edition Research Unix in 1985, and was not adopted by other variants of Unix (such as commercial Unixes or BSD). Nevertheless, it was later adopted in Plan 9 from Bell Labs, and from there was copied into some modern BSD descendants like FreeBSD. Another version of seq was written in 1994 by Ulrich Drepper, for GNU, and is now available on all Linux distributions as part of the GNU Core Utilities. The command is available as a separate package for Microsoft Windows as part of the UnxUtils collection of native Win32 ports of common GNU Unix-like utilities.[1]

Functionality edit

In its most basic use case, seq N prints out all the integers from 1 to N in sequence. This was convenient as the Unix shell at the time, the Bourne shell had no primitives for iterating over numbers, and its "for" command could only iterate over a list of words. seq was therefore used to generate such a list, as in this example:

# Remove file1 through file17: for n in `seq 17` do  rm "file$n" done 

seq had additional options for controlling the start (not just end) of the numeric sequence, its increment (a floating point number), and the formatting of the number. GNU seq changed the name and meaning of the format option (from -p to -f) and added an option to control the separator between the numbers (-s, defaults to a newline).

With other alternatives available (e.g., expr), and with more recent shells adding builtin numeric iteration, seq is less commonly used today. In the modern Linux shell, bash, the above example can be alternatively written as:

for n in {1..17} do  rm "file$n" done 

and more efficiently, without actually generating the whole sequence in advance, as

for ((n=1; n<=17; n++)) do  rm "file$n" done 

References edit

  1. ^ "Native Win32 ports of some GNU utilities". unxutils.sourceforge.net.
  1. seq manual page from 8th Edition Unix
  2. seq manual page from FreeBSD

External links edit

  • seq(1) – Linux User Commands Manual
  • seq(1) – Plan 9 Programmer's Manual, Volume 1

unix, unix, like, computer, systems, utility, generating, sequence, numbers, seqdeveloper, bell, laboratoriesinitial, releasefebruary, 1985, years, 1985, operating, systemunix, unix, like, plan, 9platformcross, platformtypecommandlicensecoreutils, gplv3, conte. On Unix like computer systems seq is a utility for generating a sequence of numbers seqDeveloper s AT amp T Bell LaboratoriesInitial releaseFebruary 1985 39 years ago 1985 02 Operating systemUnix Unix like Plan 9PlatformCross platformTypeCommandLicensecoreutils GPLv3 Contents 1 History 2 Functionality 3 References 4 External linksHistory editseq first appeared on 8th edition Research Unix in 1985 and was not adopted by other variants of Unix such as commercial Unixes or BSD Nevertheless it was later adopted in Plan 9 from Bell Labs and from there was copied into some modern BSD descendants like FreeBSD Another version of seq was written in 1994 by Ulrich Drepper for GNU and is now available on all Linux distributions as part of the GNU Core Utilities The command is available as a separate package for Microsoft Windows as part of the UnxUtils collection of native Win32 ports of common GNU Unix like utilities 1 Functionality editIn its most basic use case seq N prints out all the integers from 1 to N in sequence This was convenient as the Unix shell at the time the Bourne shell had no primitives for iterating over numbers and its for command could only iterate over a list of words seq was therefore used to generate such a list as in this example Remove file1 through file17 for n in seq 17 do rm file n done seq had additional options for controlling the start not just end of the numeric sequence its increment a floating point number and the formatting of the number GNU seq changed the name and meaning of the format option from p to f and added an option to control the separator between the numbers s defaults to a newline With other alternatives available e g expr and with more recent shells adding builtin numeric iteration seq is less commonly used today In the modern Linux shell bash the above example can be alternatively written as for n in 1 17 do rm file n done and more efficiently without actually generating the whole sequence in advance as for n 1 n lt 17 n do rm file n doneReferences edit Native Win32 ports of some GNU utilities unxutils sourceforge net seq manual page from 8th Edition Unix seq manual page from FreeBSDExternal links editseq 1 Linux User Commands Manual seq 1 Plan 9 Programmer s Manual Volume 1 Retrieved from https en wikipedia org w index php title Seq Unix amp oldid 1073622588, wikipedia, wiki, book, books, library,

article

, read, download, free, free download, mp3, video, mp4, 3gp, jpg, jpeg, gif, png, picture, music, song, movie, book, game, games.