Share to: share facebook share twitter share wa share telegram print page

Cut (Unix)

cut
Original author(s)AT&T Bell Laboratories
Developer(s)Various open-source and commercial developers
Initial releaseFebruary 1985; 39 years ago (1985-02)
Operating systemUnix, Unix-like, IBM i
PlatformCross-platform
TypeCommand
Licensecoreutils: GPLv3+

In computing, cut is a command line utility on Unix and Unix-like operating systems which is used to extract sections from each line of input — usually from a file. It is currently part of the GNU coreutils package and the BSD Base System.

Extraction of line segments can typically be done by bytes (-b), characters (-c), or fields (-f) separated by a delimiter (-d — the tab character by default). A range must be provided in each case which consists of one of N, N-M, N- (N to the end of the line), or -M (beginning of the line to M), where N and M are counted from 1 (there is no zeroth value). Since version 6, an error is thrown if you include a zeroth value. Prior to this the value was ignored and assumed to be 1.

History

The original Bell Labs version was written by Gottfried W. R. Luderer.[1][2] cut is part of the X/Open Portability Guide since issue 2 of 1987. It was inherited into the first version of POSIX.1 and the Single Unix Specification.[3] It first appeared in AT&T System III UNIX in 1982.[4]

The version of cut bundled in GNU coreutils was written by David M. Ihnat, David MacKenzie, and Jim Meyering.[5] 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.[6] The cut command has also been ported to the IBM i operating system.[7]

Examples

Assuming a file named "file" containing the lines:

foo:bar:baz:qux:quux
one:two:three:four:five:six:seven
alpha:beta:gamma:delta:epsilon:zeta:eta:theta:iota:kappa:lambda:mu
the quick brown fox jumps over the lazy dog

To output the fourth through tenth characters of each line:

$ cut -c 4-10 file
:bar:ba
:two:th
ha:beta
 quick

To output the fifth field through the end of the line of each line using the colon character as the field delimiter:

$ cut -d ":" -f 5- file
quux
five:six:seven
epsilon:zeta:eta:theta:iota:kappa:lambda:mu
the quick brown fox jumps over the lazy dog

(note that because the colon character is not found in the last line the entire line is shown)

Option -d specifies a single character delimiter (in the example above it is a colon) which serves as field separator. Option -f which specifies range of fields included in the output (here fields range from five till the end). Option -d presupposes usage of option -f.

To output the third field of each line using space as the field delimiter:

$ cut -d " " -f 3 file
foo:bar:baz:qux:quux
one:two:three:four:five:six:seven
alpha:beta:gamma:delta:epsilon:zeta:eta:theta:iota:kappa:lambda:mu
brown

(Note that because the space character is not found in the first three lines these entire lines are shown.)

To separate two words having any delimiter:

$ line=process.processid
$ cut -d "." -f1 <<< $line
process
$ cut -d "." -f2 <<< $line
processid

Syntax

cut [-b list] [-c list] [-f list] [-n] [-d delim] [-s] [file]

Flags which may be used include:

-b
Bytes; a list following -b specifies a range of bytes which will be returned, e.g. cut -b1-66 would return the first 66 bytes of a line. NB If used in conjunction with -n, no multi-byte characters will be split. NNB. -b will only work on input lines of less than 1023 bytes
-c
Characters; a list following -c specifies a range of characters which will be returned, e.g. cut -c1-66 would return the first 66 characters of a line
-f
Specifies a field list, separated by a delimiter
list
A comma separated or blank separated list of integer denoted fields, incrementally ordered. The - indicator may be supplied as shorthand to allow inclusion of ranges of fields e.g. 4-6 for ranges 4–6 or 5- as shorthand for field 5 to the end, etc.
-n
Used in combination with -b suppresses splits of multi-byte characters
-d
Delimiter; the character immediately following the -d option is the field delimiter for use in conjunction with the -f option; the default delimiter is tab. Space and other characters with special meanings within the context of the shell in use must be enquoted or escaped as necessary.
-s
Bypasses lines which contain no field delimiters when -f is specified, unless otherwise indicated.
file
The file (and accompanying path if necessary) to process as input. If no file is specified then standard input will be used.

See also

References

  1. ^ "cut(1) - OpenBSD manual pages".
  2. ^ "[TUHS] A portrait of cut(1)". 15 January 2020.
  3. ^ cut – Shell and Utilities Reference, The Single UNIX Specification, Version 4 from The Open Group
  4. ^ cut(1) – FreeBSD General Commands Manual
  5. ^ cut(1) – Linux General Commands Manual
  6. ^ "Native Win32 ports of some GNU utilities". unxutils.sourceforge.net.
  7. ^ IBM. "IBM System i Version 7.2 Programming Qshell" (PDF). IBM. Archived (PDF) from the original on 2020-09-18. Retrieved 2020-09-05.

Read other articles:

In imaging science, difference of Gaussians (DoG) is a feature enhancement algorithm that involves the subtraction of one Gaussian blurred version of an original image from another, less blurred version of the original. In the simple case of grayscale images, the blurred images are obtained by convolving the original grayscale images with Gaussian kernels having differing width (standard deviations). Blurring an image using a Gaussian kernel suppresses only high-frequency spatial information....

Matthew KomaKoma tahun 2014LahirMatthew Bair2 Juni 1987 (umur 36)Seaford, New York, Amerika SerikatPekerjaanPenyanyi, penulis lagu, DJ, produser rekamanTahun aktif2010–sekarangSuami/istriHilary Duff ​(m. 2019)​Anak1Karier musikGenrePoppunk rockEDMhip hopInstrumenVokalgitarsynthesiserkeyboardkomputerLabelCherrytreeInterscopeRCASitus webmatthewkoma.com Matthew Bair (lahir 2 Juni 1987)[1][2] dikenal secara profesional dengan nama panggungn...

Coordenadas: 20° 15' N 94° 45' E Maguai    Região   Símbolos Bandeira Localização Coordenadas 20° 15' N 94° 45' E País Myanmar Capital Maguai Características geográficas População total (2019) 3 937 278 hab. Maguai[1] (em birmanês: Magway) é um estado da Birmânia (ou Mianmar), cuja capital é Maguai. De acordo com o censo de 2019, havia 3 937 278 habitantes.[2] Referências ↑ Almanaque 1995. ↑ CP 2019. Bibliograf...

ملخص معلومات الملف وصف هذا شعار: Patrick Star مصدر (https://alchetron.com/Patrick-Star-4041391-W) تاريخ 1999 منتج SpongeBob SquarePants الإذن(إعادة الاستخدام) انظر أدناه نسخ أخرى لا ترخيص هذه الصورة هي توضيح لشخصية أو شخصيات خيالية من مجلة قصص مصورة، أو لعبة فيديو، أو برنامج رسوم متحركة تلفزيونيّ أو سينمائيّ. هذه

هذه المقالة يتيمة إذ تصل إليها مقالات أخرى قليلة جدًا. فضلًا، ساعد بإضافة وصلة إليها في مقالات متعلقة بها. (أغسطس 2019) إيرين بارنت معلومات شخصية الميلاد 2 سبتمبر 1996 (27 سنة)  جبل طارق  مركز اللعب مدافع الجنسية المملكة المتحدة  معلومات النادي النادي الحالي St Joseph's F.C. [الإ

العلاقات التوفالية الكورية الجنوبية توفالو كوريا الجنوبية   توفالو   كوريا الجنوبية تعديل مصدري - تعديل   العلاقات التوفالية الكورية الجنوبية هي العلاقات الثنائية التي تجمع بين توفالو وكوريا الجنوبية.[1][2][3][4][5] مقارنة بين البلدين هذه مقارن

Photography genre and techniques of extreme close-up pictures Compare macrographs, photomicrographs, and microphotographs. Macro photograph of a common yellow dung fly (Scathophaga stercoraria) made using a lens at its maximum 1:1 reproduction ratio, and an 18×24mm image sensor, the on-screen display of the photograph results in a greater than life-size image. Headshot of a dragonfly taken with a 100 mm macro lens coupled with a 50 mm lens in reverse at the end Macro photograph of ...

Japanese TV series or program JinPromotional posterAlso known asJIN-仁-GenreSci-fi medicalDramaFantasyBased onJinby Motoka MurakamiWritten byMurakami Motoka (manga)Morishita YoshikoDirected byHirakawa YuichiroYamamuro DaisukeKawashima RyutaroStarringTakao OsawaHaruka AyaseMiki NakataniMasaaki UchinoCountry of originJapanOriginal languageJapaneseNo. of seasons2No. of episodes22ProductionProducersIshimaru Akihiko Tsuru MasaakiProduction locationJapanRunning timeapproximately 60 MinutesOri...

1997 World Weightlifting ChampionshipsMenWomen54 kg46 kg59 kg50 kg64 kg54 kg70 kg59 kg76 kg64 kg83 kg70 kg91 kg76 kg99 kg83 kg108 kg+83 kg+108 kgvte Main article: 1997 World Weightlifting Championships The 1997 World Weightlifting Championships were held in Chiang Mai, Thailand from December 6 to December 14. The men's competition in the 59 kg division was staged on 7 December 1997. Medalists Event Gold Silver Bronze Snatch  William Vargas (CUB) 132.5 kg  Stefan Georg...

Gangsta for Life redirects here. For the Rihanna song G4L, see Rated R (Rihanna album). This article does not cite any sources. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: Gangsta for Life: The Symphony of David Brooks – news · newspapers · books · scholar · JSTOR (May 2021) (Learn how and when to remove this template message) 2007 studio album by MavadoGan...

OECD各国の合計特殊出生率。上位国のひとつから、50年後には最下位国となった。 大韓民国の少子化(だいかんみんこくのしょうしか、韓: 대한민국의 저출산)について解説する。大韓民国(韓国)では21世紀以降、著しい少子化が起こっている。韓国の合計特殊出生率は1970年代まで6.0~4.0と世界最高レベルの数値で推移していたが、1983年に初めて人口置換水準を下回る...

Kathakali is popular art form in Kerala The population of Kerala, India is a heterogenous group that comprises many ethnic groups that originated in other parts of India as well as the world, with distinctive cultural and religious traditions. While the majority of Keralites speak the Malayalam language, various ethnic groups may speak other languages as well.[1][2] The racial and ethnic history of Kerala is highly controversial and disputed among the cultural anthropologists,...

Pour les articles homonymes, voir Leme (homonymie). LemeGéographiePays  BrésilEntité territoriale administrative Área de Planejamento 2 (d)Municipalité Rio de JaneiroEntité territoriale administrative Zona Sul (d)Sous-préfecture South Zone of Rio de Janeiro (d)Région administrative Copacabana (d)Coordonnées 22° 57′ 44″ S, 43° 10′ 00″ OFonctionnementStatut Quartier de Rio de Janeiro (d)modifier - modifier le code - modifier Wikidata Cet art...

ABMC cemetery in Lorraine, France 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: Epinal American Cemetery and Memorial – news · newspapers · books · scholar · JSTOR (February 2014) (Learn how and when to remove this template message) Epinal American Cemetery and MemorialEpinal American Cemetery and Memorial...

18th episode of the 3rd season of Heroes ExposedHeroes episodeREBEL tells Peter Petrelli (Milo Ventimiglia) and Matt Parkman (Greg Grunberg) where Daphne Millbrook (Brea Grant) is.Episode no.Season 3Episode 18Directed byEric LaneuvilleWritten byAdam Armus and Kay FosterProduction code318Original air dateMarch 2, 2009 (2009-03-02)Guest appearances Ashley Crow as Sandra Bennet Dan Byrd as Luke Campbell David H. Lawrence XVII as Eric Doyle Justin Baldoni as Alex Woolsley Tayl...

2009 video gameNeighborhood GamesDeveloper(s)Jet Black GamesPublisher(s)THQPlatform(s)WiiReleaseJanuary 12, 2009Genre(s)PartyMode(s)Players: 1–4 Neighborhood Games, known in PAL regions as Big Family Games, is a party video game developed by Canadian studio Jet Black Games and published by THQ. It was released for the Wii in North America on January 12, 2009.[1] Gameplay Screenshot of Neighborhood Games Neighborhood Games offers players 24 versions of neighborhood games, including f...

Digital cameras produced by Fujifilm Fujifilm XF1, X-E1 and X10 The Fujifilm X series is a line of digital cameras produced by Fujifilm. The series encompasses fixed lens and interchangeable lens mirrorless cameras and premium compact point-and-shoot cameras aimed at consumer, enthusiast and professional photographers.[1] The X series is part of the larger FinePix range of digital cameras from Fujifilm. The X series models use either APS-C or 2⁄3 inch sensors. Fujifilm X series ...

Oriental dance redirects here. For oriental dance in popular culture, see Belly dance. 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: Middle Eastern dance – news · newspapers · books · scholar · JSTOR (February 2022) (Learn how and when to remove this template message) A group of Emiratis perform the tradit...

2

「TWO」はこの項目へ転送されています。 CHEMISTRYの楽曲については「PIECES OF A DREAM」をご覧ください。 KAT-TUNの楽曲については「ULTIMATE WHEELS」をご覧ください。 大野智 (嵐) の楽曲「two」については「Popcorn (嵐のアルバム)」をご覧ください。 「弐」はこの項目へ転送されています。 大宰府の職名である「弐」(すけ)については「大宰府#職員」をご覧ください。 優里の...

English footballer For the footballer of the 1960s, see Tony Kay. For the baseball player, see Anthony Kay. Antony Kay Kay playing for Tranmere Rovers in 2009Personal informationFull name Antony Roland Kay[1]Date of birth (1982-10-21) 21 October 1982 (age 41)[2]Place of birth Barnsley, England[3]Height 5 ft 11 in (1.80 m)[4]Position(s) Defender; midfielderTeam informationCurrent team Bala TownYouth career0000–1999 BarnsleySenior career*Yea...

Kembali kehalaman sebelumnya