Sort (유닉스)

sort
개발자AT&T 벨 연구소
발표일1971년 11월 3일(53년 전)(1971-11-03)
운영 체제유닉스, 유닉스 계열, MSX-DOS
종류명령어
라이선스coreutils: GNU GPL v3

sort는 표준 유닉스 명령어 프로그램으로서 입력어들이나 인수 목록들에 기입된 모든 파일들의 연속어들을 정렬된 순서로 출력한다. 정렬하기는 입력어 각각으로부터 도출된 하나 혹은 그 이상의 정렬 키들에 바탕을 두어 시행된다. 디폴트에 의해서 전체 입력어는 정렬 키로 처리된다. 빈 공백은 디폴트 필드 구분자로서 처리되어 사용된다. -r 플래그는 정렬 명령을 반대로 시행한다.

옵션

정렬 옵션

-b: 선행 공백 무시한다.

-f: 영어 소문자를 대문자로 처리한다. 즉, 대소문자 구별안한다.

-n: 비교 대상을 텍스트내의 숫자로 한정하여 정렬한다.

-R: 해시의 키값 기준으로 랜덤하게 정렬한다.

-r: 비교 결과를 역순(내림차순)으로 정렬한다.

확장 옵션

-c: 파일이 정렬되어 있는지 검사한다.

-k n: n번째 필드를 기준으로 정렬한다.

-m: 이미 정렬된 파일들을 병합한다. (정렬은 하지 않는다.)

-o: 표준 출력 대신 저장할 파일명을 명시한다.

-t: 필드 구분자를 지정해준다. (기본 구분자는 공백이다.)

-u: 정렬 후 중복된 내용을 제거한다.

현재 디렉터리를 파일 크기에 따라 정렬하기

$ ls -s | sort -n
  96 Nov1.txt
 128 _arch_backup.lst
 128 _arch_backup.lst.tmp
1708 NMON

알파벳 순서로 파일 정렬하기

$ cat phonebook
Smith, Brett     555-4321
Doe, John        555-1234
Doe, Jane        555-3214
Avery, Cory      555-4321
Fogarty, Suzie   555-2314
$ sort phonebook
Avery, Cory      555-4321
Doe, Jane        555-3214
Doe, John        555-1234
Fogarty, Suzie   555-2314
Smith, Brett     555-4321

숫자로 정렬하기

-n 옵션은 프로그램이 숫자값에 따라 정렬되도록 만든다:

$ du /bin/* | sort -n
4       /bin/domainname
24      /bin/ls
102     /bin/sh
304     /bin/csh

sort의 과거 버전에서는, +1 옵션은 프로그램 데이터의 두 번째 열을 ( +2은 세 번째 열을 정렬하고 나머지도 이와 같은 식으로) 정렬되도록 한다. 이것이 더 이상 지속되지 않는 경우, 대신 -k 옵션을 사용하여 같은 일을 한다. (주의 : "-k2"는 두 번째 열에 대한 것이다):

$ cat zipcode
Adam  12345
Bob   34567
Joe   56789
Sam   45678
Wendy 23456
$ sort -nk 2 zipcode
Adam  12345
Wendy 23456
Bob   34567
Sam   45678
Joe   56789

파이프로 한정된 파일 정렬하기

$ sort -t':' -k2 zipcode
Adam|12345
Wendy|23456
Bob|34567
Sam|45678
Joe|56789

반대로 정렬하기

-r 옵션은 단순히 정렬하기 순서를 반대로 뒤집는다:

$ sort -nrk 2 zipcode
Joe   56789
Sam   45678
Bob   34567
Wendy 23456
Adam  12345

같이 보기

외부 링크

Read other articles:

السادة الأفاضل الثلاثةThe Three Caballeros (بالإنجليزية) معلومات عامةالتصنيف فيلم رسوم متحركة حية — فلم أنثولوجيا الصنف الفني  القائمة ... فيلم موسيقي — فيلم للأطفال — فيلم رسوم متحركة تحريكًا تقليديًّا — فيلم فنتازيا — فيلم عائلي — كوميديا تاريخ الصدور 21 ديسمبر 1944[1] (المك...

 

Santa Luzia Municipio BanderaEscudo Lema: Hodie et Semper Nihil Déficit MapaCoordenadas 19°46′12″S 43°51′03″O / -19.77, -43.850833333333Idioma oficial PortuguésEntidad Municipio • País Brasil • Estado Minas Gerais • Mesorregión Metropolitana de Belo Horizonte • Microrregión Belo HorizontePrefecto Gilberto Dorneles (PMDB). Hasta el 2012.Fundación 18 de marzo de 1847Superficie   • Total 233.759 km²Altitud   • M...

 

WineSingel oleh Suran featuring Changmodari album Walkin'BahasaKoreaDirilis27 April 2017 (2017-04-27)Genre Hip hop R&B Durasi3:52LabelMillion MarketPenciptaSuranSlow RabbitChangmoJuneProduserSugaKronologi singel Suran Winter Bird (2016) Wine (2017) 1+1=0 (2017) Wine (bahasa Korea: 오늘 취하면; har. Andai Saja Hari Ini Aku Mabuk) (digayakan dengan huruf besar) adalah lagu oleh penyanyi-penulis lagu Korea Selatan Suran featuring raper Changmo. Dirilis sebagai singel digit...

Wapen van Göteborgs och Bohuslän Älvsborgs län, Göteborgs och Bohus län en Skaraborgs län binnen de nieuwe provincie Västra Götalands län Göteborgs och Bohus län is een voormalig län, een voormalige provincie in het westen van Zweden. De provincie bestond uit het landschap Bohuslän, het westelijke deel van Västergötland en Lindome in het noorden van Halland. Lindome was de parochie. De provincie bestond tot 31 december 1998, daarna ging de provincie met Älvsborgs län en grot...

 

A demon in Greek and Byzantine mythology For other uses, see Gello (disambiguation). This article or section should specify the language of its non-English content, using {{lang}}, {{transliteration}} for transliterated languages, and {{IPA}} for phonetic transcriptions, with an appropriate ISO 639 code. Wikipedia's multilingual support templates may also be used - notably grc for Ancient Greek. See why. (September 2021) Gello (...

 

Plausibilität ist ein Beurteilungskriterium für Aussagen: Wird eine Aussage als plausibel beurteilt, so ist sie einleuchtend, verständlich, begreiflich etc. Inhaltsverzeichnis 1 Etymologie 2 Wissenschaftliche Präzisierung des Begriffs 3 Abgrenzung 3.1 Wissenschaftstheorie 3.2 Plausibilitätskontrolle 3.3 Plausibilitätsregel 3.4 Mathematik 3.5 Geschichte 4 Literatur 5 Weblinks 6 Einzelnachweise Etymologie Das Adjektiv plausibel wurde ab der zweiten Hälfte des 17. Jahrhunderts von dem gle...

1964 Indian filmPoompuharTheatrical release posterDirected byP. NeelakantanScreenplay byM. KarunanidhiStory byIlango AdigalStarringS. S. RajendranC. R. VijayakumariRajasreeK. B. SundarambalMusic byR. SudarsanamProductioncompanyMekala PicturesDistributed bySSR PicturesRelease date 18 September 1964 (1964-09-18) CountryIndiaLanguageTamil Poompuhar is a 1964 Indian Tamil-language epic film directed by P. Neelakantan and written by M. Karunanidhi. It is the second film based on the...

 

Португальське вторгнення до ГвінеїВійна за незалежність Гвінеї-БісауКолоніальна війна ПортугаліїДата22 листопада 1970МісцеКонакрі, ГвінеяПричина прагнення Гвінеї-Бісау до незалежності від ПортугаліїРезультат португальці не змогли захопити або вбити Амілкара Кабрала ...

 

Minor league baseball teamFrisco RoughRidersFounded in 2003 Frisco, Texas Team logo Cap insignia Minor league affiliationsClassDouble-A (2003–present)LeagueTexas League (2022–present)DivisionSouth DivisionPrevious leagues Double-A Central (2021) Texas League (2003–2020) Major league affiliationsTeamTexas Rangers (2003–present)Minor league titlesLeague titles (2)20042022Division titles (6)200320042008201220212022First-half titles (6)200320072008201020122014Second-half titles (4)2004200...

This article is about the television series. For the film of the same name, see Do Lafzon Ki Kahani (film). This article relies largely or entirely on a single source. Relevant discussion may be found on the talk page. Please help improve this article by introducing citations to additional sources.Find sources: Do Lafzon Ki Kahani TV series – news · newspapers · books · scholar · JSTOR (October 2023) Indian TV series or programme Do Lafzon Ki...

 

City in Minnesota, United States City in Minnesota, United StatesNew MunichCityMotto: Zu viel zu trinken ist eine gute Idee.Location of New Munichwithin Stearns County, MinnesotaCoordinates: 45°37′43″N 94°45′12″W / 45.62861°N 94.75333°W / 45.62861; -94.75333CountryUnited StatesStateMinnesotaCountyStearnsGovernment • MayorShawn DuevelArea[1] • Total0.53 sq mi (1.38 km2) • Land0.53 sq m...

 

Japanese pharmaceutical company Ono Pharmaceutical Co., Ltd.Native name小野薬品工業TypePublic (K.K)Traded asTYO: 4528ISINJP3197600004IndustryPharmaceuticalsFounded1717; 306 years ago (1717) as Fushimiya Ichibei apothecaryFounderIchibei Ono IHeadquartersChuo-ku, Osaka, 541-8564, JapanArea servedWorldwideKey peopleGyo Sagara(President and CEO)ProductsPharmaceuticalsDiagnostic reagentsRevenue JPY 261.8 billion (FY 2017) (US$ 2.4 billion) (FY 2017)Net income JPY 50.2 billi...

Arnold Lakhovsky, The Conversation (sekitar 1935) Percakapan (bahasa Inggris: conversation) adalah komunikasi interaktif antara dua orang atau lebih. Pengembangan keterampilan percakapan dan etiket merupakan bagian penting dari sosialisasi. Pengembangan keterampilan percakapan dalam bahasa baru sering menjadi fokus pengajaran dan pembelajaran bahasa. Analisis percakapan adalah cabang sosiologi yang mempelajari struktur dan organisasi interaksi manusia, dengan fokus yang lebih spesifik pad...

 

DC Comics character This article is about the DC character. For the heavy metal band, see Slipknot (band). For other uses, see Slipknot (disambiguation). Comics character SlipknotInterior artwork from Millennium #4 (January 1988).Art by Joe Staton.Publication informationPublisherDC ComicsFirst appearanceThe Fury of Firestorm #28 (October 1984)Created byGerry ConwayRafael KayananIn-story informationAlter egoChristopher WeissSpeciesHumanTeam affiliationsSuicide SquadKobra Cult2000 CommitteeSecr...

 

مطار كاجو كاجو إياتا: n/a – ايكاو: HSKJ Kago Kajuموقع المطار موجز نوع المطار عام، مدني يخدم جنوب السودان البلد جنوب السودان  الموقع  جنوب السودان الارتفاع 762 م؛ 2,500 قدم إحداثيات 03°55′01″N 31°40′01″E / 3.91694°N 31.66694°E / 3.91694; 31.66694 (Kago Kaju Airport) الخريطة مدارج الاتجاه الطول ...

This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: Flypaper 1999 film – news · newspapers · books · scholar · JSTOR (May 2019) (Learn how and when to remove this template message) 1999 American filmFlypaperDVD coverDirected byKlaus HochWritten byKlaus HochProduced byDavid R. GinsburgStarringCraig ShefferRo...

 

South Korean video game developer This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: WeMade Entertainment – news · newspapers · books · scholar · JSTOR (January 2012) (Learn how and when to remove this template message) WemadeNative name위메이드TypePrivate companyIndustryVideo gamesFounded2000FoundersKwan H...

 

Railway station in Burlington, Ontario, Canada For other uses, see Burlington Station (disambiguation). BurlingtonGeneral informationLocation2101 Fairview St.Burlington, OntarioCanadaCoordinates43°20′27″N 79°48′34″W / 43.34083°N 79.80944°W / 43.34083; -79.80944Owned byMetrolinxPlatforms2 island platformsTracks4ConnectionsBurlington TransitConstructionStructure typeStation buildingParking2,273 spacesBicycle facilitiesRackAccessibleYesOther informationStation...

В Википедии есть статьи о других людях с фамилией Тараненко. Леонид Тараненко Леонид Тараненко выполняет рывок. 1986 год, ГДР Личная информация Пол мужской Полное имя Леонид Аркадьевич Тараненко Страна  СССР Белоруссия Специализация тяжёлая атлетика Дата рождения 13 ...

 

British chemist (1837–1898) John NewlandsBorn(1837-11-26)26 November 1837Lambeth, London, EnglandDied21 July 1898(1898-07-21) (aged 60)Lower Clapton, Middlesex, EnglandAlma materRoyal College of ChemistryImperial College LondonKnown forPeriodic table, law of octavesAwardsDavy Medal (1887)Scientific careerFieldsAnalytical chemistry John Alexander Reina Newlands (26 November 1837 – 29 July 1898) was a British chemist who worked concerning the periodicity of elements.[1 ...

 

Strategi Solo vs Squad di Free Fire: Cara Menang Mudah!