Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

join (Unix)

From Wikipedia, the free encyclopedia
Command in Unix-like operating systems
join
Original authorDouglas McIlroy
DeveloperAT&T Bell Laboratories
Initial releaseJanuary 1979; 47 years ago (1979-01)
Written inC
Operating systemUnix,Unix-like,Plan 9
PlatformCross-platform
TypeCommand
Licensecoreutils:GPLv3+
Plan 9:MIT License

join is a command inUnix andUnix-likeoperating systems that merges the lines of two sortedtext files based on the presence of a commonfield. It is similar to the join operator used inrelational databases but operating on text files.

Overview

[edit]

Thejoin command takes as input two text files and several options. If nocommand-line argument is given, this command looks for a pair of lines from the two files having the same first field (a sequence of characters that are different from space), and outputs a line composed of the first field followed by the rest of the two lines.

The program arguments specify whichcharacter to be used in place of space to separate the fields of the line, which field to use when looking for matching lines, and whether to output lines that do not match. The output can be stored to another file rather than printed usingredirection.

As an example, the two following files list the known fathers and the mothers of some people. Both files have been sorted on the join field — this is a requirement of the program.

george jimkumar gunaware
albert marthageorge sophie

The join of these two files (with no argument) would produce:

george jim sophie

Indeed, only "george" is common as a first word of both files.

Examples

[edit]

To findPythagorean triples of the form(k, k+1, n).

$join<(foriin{1..9999};doprintf--'%010d\t%s\t%s\t%s\n'"$((2*i*(i+1)+1))""$i""$((i+1))";done)<(foriin{1..9999};doprintf--'%010d\t%s\n'"$((i**2))""$i";done)0000000025 3 4  50000000841 20 21  290000028561 119 120  1690000970225 696 697  9850032959081 4059 4060  5741

History

[edit]

join is intended to be a relation database operator. It is part of theX/Open Portability Guide since issue 2 of 1987. It was inherited into the first version of POSIX.1 and theSingle Unix Specification.[1][2]

The version ofjoin bundled inGNUcoreutils was written by Mike Haertel.[3] The command is available as a separate package forMicrosoft Windows as part of theUnxUtils collection ofnativeWin32ports of common GNU Unix-like utilities.[4]

See also

[edit]

References

[edit]
  1. ^printf – Shell and Utilities Reference,The Single UNIX Specification, Version 5 fromThe Open Group
  2. ^printf(1) – FreeBSD General CommandsManual
  3. ^join(1) – Linux General CommandsManual from ManKier.com
  4. ^"Native Win32 ports of some GNU utilities".unxutils.sourceforge.net.Archived from the original on 2006-02-09. Retrieved2026-02-03.

External links

[edit]
The WikibookGuide to Unix has a page on the topic of:Commands
File system
Processes
User environment
Text processing
Shell builtins
Searching
Documentation
Software development
Miscellaneous
File system
Processes
User environment
Text processing
Shell builtins
Networking
Searching
Software development
Miscellaneous
File system
Text utilities
Shell utilities
Retrieved from "https://en.wikipedia.org/w/index.php?title=Join_(Unix)&oldid=1336332552"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2026 Movatter.jp