- c list The list specifies character positions.

Similar documents
File Commands. Objectives

psed [-an] script [file...] psed [-an] [-e script] [-f script-file] [file...]

Regular Expressions. Todd Kelley CST8207 Todd Kelley 1

CS160A EXERCISES-FILTERS2 Boyd

Table of contents. Our goal. Notes. Notes. Notes. Summer June 29, Our goal is to see how we can use Unix as a tool for developing programs

User Commands sed ( 1 )

Linux Text Utilities 101 for S/390 Wizards SHARE Session 9220/5522

Configuring the RADIUS Listener LEG

2) clear :- It clears the terminal screen. Syntax :- clear

Unix as a Platform Exercises + Solutions. Course Code: OS 01 UNXPLAT

Part III. Shell Config. Tobias Neckel: Scripting with Bash and Python Compact Max-Planck, February 16-26,

ISO/IEC JTC1/SC22/WG20 N

Mineração de Dados Aplicada

More Scripting and Regular Expressions. Todd Kelley CST8207 Todd Kelley 1

Basic Unix Command. It is used to see the manual of the various command. It helps in selecting the correct options

Reference number of working document: Reference number of document: ISO/IEC FCD

lsx [ls_options ] [names]

Information technology. Specification method for cultural conventions ISO/IEC JTC1/SC22/WG20 N690. Reference number of working document:

5/8/2012. Exploring Utilities Chapter 5

Module 8 Pipes, Redirection and REGEX

TECHNICAL ISO/IEC REPORT TR 14652

Configuring the RADIUS Listener Login Event Generator

Shell Programming Overview

UNIX, GNU/Linux and simple tools for data manipulation

Basics. I think that the later is better.

Reading and manipulating files

UNIX / LINUX - REGULAR EXPRESSIONS WITH SED

Advanced training. Linux components Command shell. LiLux a.s.b.l.

Paolo Santinelli Sistemi e Reti. Regular expressions. Regular expressions aim to facilitate the solution of text manipulation problems

C mini reference. 5 Binary numbers 12

Week Overview. Simple filter commands: head, tail, cut, sort, tr, wc grep utility stdin, stdout, stderr Redirection and piping /dev/null file

Unix Introduction to UNIX

Utility Commands. Note. System Management Command Reference for Cisco NCS 6000 Series Routers 1

CS Unix Tools. Fall 2010 Lecture 5. Hussam Abu-Libdeh based on slides by David Slater. September 17, 2010

sed, a stream editor version 4.2.1, 25 June 2009 by Ken Pizzini, Paolo Bonzini

Regex, Sed, Awk. Arindam Fadikar. December 12, 2017

Bash Reference Manual Reference Documentation for Bash Edition 2.5b, for Bash Version 2.05b. July 2002

CS 4218 Software Testing and Debugging Ack: Tan Shin Hwei for project description formulation

Text processing. Adam Belloum ESA 2014/2015. Material Prepared by Eelco Schatborn

FSASIM: A Simulator for Finite-State Automata

Linux & Shell Programming 2014

More text file manipulation: sorting, cutting, pasting, joining, subsetting,

QUESTION BANK ON UNIX & SHELL PROGRAMMING-502 (CORE PAPER-2)

Common File System Commands

AWK - PRETTY PRINTING

User Commands ls ( 1 )

INTERNATIONAL ISO/IEC WD10 STANDARD. Information technology Specification methods for cultural conventions

CSE II-Sem)

CST Lab #5. Student Name: Student Number: Lab section:

Unix as a Platform Exercises. Course Code: OS-01-UNXPLAT

Introduction to Bash Programming. Dr. Xiaolan Zhang Spring 2013 Dept. of Computer & Information Sciences Fordham University

Bashed One Too Many Times. Features of the Bash Shell St. Louis Unix Users Group Jeff Muse, Jan 14, 2009

Operating Systems, Unix Files and Commands SEEM

User Commands find ( 1 )

sottotitolo A.A. 2016/17 Federico Reghenzani, Alessandro Barenghi

CS214-AdvancedUNIX. Lecture 2 Basic commands and regular expressions. Ymir Vigfusson. CS214 p.1

CSE2031. Lab 2 FALL 2009

More Scripting and Regular Expressions. Todd Kelley CST8207 Todd Kelley 1

Lecture 5. Essential skills for bioinformatics: Unix/Linux

A Brief Introduction to the Linux Shell for Data Science

Gabriel Hugh Elkaim Spring CMPE 013/L: C Programming. CMPE 013/L: C Programming

Utilities. September 8, 2015

Chapter 4: Computer Codes. In this chapter you will learn about:

5/8/2012. Encryption-based Protection. Protection based on Access Permission (Contd) File Security, Setting and Using Permissions Chapter 9

Contents. Volume 1 Base Definitions, Issue

STREAM EDITOR - REGULAR EXPRESSIONS

68000 Assembler by Paul McKee. User's Manual

Shells and Shell Programming

Muntaser Abulafi Yacoub Sabatin Omar Qaraeen. C Data Types

5/20/2007. Touring Essential Programs

Overview. Unix/Regex Lab. 1. Setup & Unix review. 2. Count words in a text. 3. Sort a list of words in various ways. 4.

Chapter 4. Unix Tutorial. Unix Shell

Shells and Shell Programming

Control Flow Statements. Execute all the statements grouped in the brackets. Execute statement with variable set to each subscript in array in turn

Bash scripting Tutorial. Hello World Bash Shell Script. Super User Programming & Scripting 22 March 2013

CS Advanced Unix Tools & Scripting

bash, part 3 Chris GauthierDickey

Shells & Shell Programming (Part B)

VHDL Lexical Elements

Lexical Considerations

Appendix A GLOSSARY. SYS-ED/ Computer Education Techniques, Inc.

LESSON 4. The DATA TYPE char

User Commands tar ( 1 )

Computers Programming Course 5. Iulian Năstac

Fundamentals of Programming. Lecture 11: C Characters and Strings

Regular Expressions. Michael Wrzaczek Dept of Biosciences, Plant Biology Viikki Plant Science Centre (ViPS) University of Helsinki, Finland

Information technology Portable Operating System Interface (POSIX ) Part 3: Shell and Utilities


The input can also be taken from a file and similarly the output can be redirected to another file.

CPSC 217 Midterm (Python 3 version)

1 Lexical Considerations

Skip the first SKIP1 bytes of FILE1 and the first SKIP2 bytes of FILE2. l verbose Output byte numbers and values of all differing bytes.

Regular Expressions. Regular expressions are a powerful search-and-replace technique that is widely used in other environments (such as Unix and Perl)

ITST Searching, Extracting & Archiving Data

>B<82. 2Soft ware. C Language manual. Copyright COSMIC Software 1999, 2001 All rights reserved.

UNIX files searching, and other interrogation techniques

VI Commands Cheat Sheets

Unix/Linux Primer. Taras V. Pogorelov and Mike Hallock School of Chemical Sciences, University of Illinois

MULTIPLE CHOICE. Chapter Seven

VARIABLES AND CONSTANTS

Transcription:

CUT(1) BSD General Commands Manual CUT(1)... 1 PASTE(1) BSD General Commands Manual PASTE(1)... 3 UNIQ(1) BSD General Commands Manual UNIQ(1)... 5 HEAD(1) BSD General Commands Manual HEAD(1)... 7 TAIL(1) BSD General Commands Manual TAIL(1)... 8 TR(1) BSD General Commands Manual TR(1)... 10 CUT(1) BSD General Commands Manual CUT(1) NAME cut - cut out selected portions of each line of a file SYNOPSIS cut - b list [- n] [file...] cut - c list [file...] cut - f list [- d delim] [- s] [file...] DESCRIPTION The cut utility cuts out selected portions of each line (as specified by list) from each file and writes them to the standard output. If no file arguments are specified, or a file argument is a single dash (`- '), cut reads from the standard input. The items specified by list can be in terms of column position or in terms of fields delimited by a special character. Column numbering starts from 1. The list option argument is a comma or whitespace separated set of num- bers and/or number ranges. Number ranges consist of a number, a dash (`- '), and a second number and select the fields or columns from the first number to the second, inclusive. Numbers or number ranges may be preceded by a dash, which selects all fields or columns from 1 to the last number. Numbers or number ranges may be followed by a dash, which selects all fields or columns from the last number to the end of the line. Numbers and number ranges may be repeated, overlapping, and in any order. If a field or column is specified multiple times, it will appear only once in the output. It is not an error to select fields or columns not present in the input line. The options are as follows: - b list The list specifies byte positions. - c list The list specifies character positions. - d delim Use delim as the field delimiter character instead of the tab

character. - f list The list specifies fields, separated in the input by the field delimiter character (see the - dd option.) Output fields are sepa- rated by a single occurrence of the field delimiter character. - n - s Do not split multi- byte characters. Characters will only be out- put if at least one byte is selected, and, after a prefix of zero or more unselected bytes, the rest of the bytes that form the character are selected. Suppress lines with no field delimiter characters. Unless speci- fied, lines with no delimiters are passed through unmodified. ENVIRONMENT The LANG, LCALL and LCCTYPE environment variables affect the execution of cut as described in environ(7). EXIT STATUS The cut utility exits 0 on success, and >0 if an error occurs. EXAMPLES Extract users' login names and shells from the system passwd(5) file as ``name:shell'' pairs: cut - d : - f 1,7 /etc/passwd Show the names and login times of the currently logged in users: who cut - c 1-16,26-38 SEE ALSO colrm(1), paste(1) STANDARDS The cut utility conforms to IEEE Std 1003.2-1992 (``POSIX.2''). HISTORY A cut command appeared in AT&T System III UNIX. BSD December 21, 2006 BSD

PASTE(1) BSD General Commands Manual PASTE(1) NAME paste - - merge corresponding or subsequent lines of files SYNOPSIS paste [- s] [- d list] file... DESCRIPTION The ppaassttee utility concatenates the corresponding lines of the given input files, replacing all but the last file's newline characters with a single tab character, and writes the resulting lines to standard output. If end- of- file is reached on an input file while other input files still contain data, the file is treated as if it were an endless source of empty lines. The options are as follows: - d list Use one or more of the provided characters to replace the newline characters instead of the default tab. The charac- ters in list are used circularly, i.e., when list is exhausted the first character from list is reused. This con- tinues until a line from the last input file (in default operation) or the last line in each file (using the - s option) is displayed, at which time ppaassttee begins selecting characters from the beginning of list again. The following special characters can also be used in list: \n newline character \t tab character \\ backslash character \0 Empty string (not a null character). Any other character preceded by a backslash is equivalent to the character itself. - s Concatenate all of the lines of each separate input file in command line order. The newline character of every line except the last line in each input file is replaced with the tab character, unless otherwise specified by the - - dd option. If `- ' is specified for one or more of the input files, the standard input is used; standard input is read one line at a time, circularly, for each instance of `- '. EXIT STATUS The paste utility exits 0 on success, and >0 if an error occurs.

EXAMPLES List the files in the current directory in three columns: ls paste - - - Combine pairs of lines from a file into single lines: paste - s - d '\t\n' myfile Number the lines in a file, similar to nl(1): sed = myfile paste - s - d '\t\n' - - Create a colon- separated list of directories named bin, suitable for use in the PATH environment variable: find / - name bin - type d paste - s - d : - BSD June 25, 2004 BSD

UNIQ(1) BSD General Commands Manual UNIQ(1) NAME uniq - - report or filter out repeated lines in a file SYNOPSIS uniq [- c - d - u] [- i] [- f num] [- s chars] [inputfile [outputfile]] DESCRIPTION The uunniiqq utility reads the specified inputfile comparing adjacent lines, and writes a copy of each unique input line to the outputfile. If inputfile is a single dash (`- ') or absent, the standard input is read. If outputfile is absent, standard output is used for output. The second and succeeding copies of identical adjacent input lines are not written. Repeated lines in the input will not be detected if they are not adja- cent, so it may be necessary to sort the files first. The following options are available: - c - d Precede each output line with the count of the number of times the line occurred in the input, followed by a single space. Only output lines that are repeated in the input. - f num Ignore the first num fields in each input line when doing compar- isons. A field is a string of non- blank characters separated from adjacent fields by blanks. Field numbers are one based, i.e., the first field is field one. - s chars Ignore the first chars characters in each input line when doing comparisons. If specified in conjunction with the - - ff option, the first chars characters after the first num fields will be ignored. Character numbers are one based, i.e., the first char- acter is character one. - u - i Only output lines that are not repeated in the input. Case insensitive comparison of lines. ENVIRONMENT The LANG, LC_ALL, LCOLLATE and LC_CTYPE environment variables affect the execution of uniq as described in environ(7).

EXIT STATUS The uniq utility exits 0 on success, and >0 if an error occurs. BSD July 3, 2004 BSD

HEAD(1) BSD General Commands Manual HEAD(1) NAME head - - display first lines of a file SYNOPSIS head [- n count - c bytes] [file...] DESCRIPTION This filter displays the first count lines or bytes of each of the speci- fied files, or of the standard input if no files are specified. If count is omitted it defaults to 10. If more than a single file is specified, each file is preceded by a header consisting of the string ``==> XXX <=='' where ``XXX'' is the name of the file. EXIT STATUS The head utility exits 0 on success, and >0 if an error occurs. BSD June 6, 1993 BSD - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

File: *manpages*, Node: tail, Up: (dir) TAIL(1) BSD General Commands Manual TAIL(1) NAME tail - - display the last part of a file SYNOPSIS tail [- F - f - r] [- q] [- b number - c number - n number] [file...] DESCRIPTION The tail utility displays the contents of file or, by default, its stan- dard input, to the standard output. The display begins at a byte, line or 512- byte block location in the input. Numbers having a leading plus (`+') sign are relative to the beginning of the input, for example, ``- c +2'' starts the display at the second byte of the input. Numbers having a leading minus (`- ') sign or no explicit sign are relative to the end of the input, for example, ``- n 2'' displays the last two lines of the input. The default starting loca- tion is ``- n 10'', or the last 10 lines of the input. The options are as follows: - b number The location is number 512- byte blocks. - c number The location is number bytes. - f - F The - f option causes tail to not stop when end of file is reached, but rather to wait for additional data to be appended to the input. The - f option is ignored if the standard input is a pipe, but not if it is a FIFO. The - F option implies the - f option, but tail will also check to see if the file being followed has been renamed or rotated. The file is closed and reopened when tail detects that the filename being read from has a new inode number. The - F option is ignored if reading from standard input rather than a file. - n number The location is number lines. - q Suppresses printing of headers when multiple files are being examined.

- r The - r option causes the input to be displayed in reverse order, by line. Additionally, this option changes the meaning of the - b, - c and - n options. When the - r option is specified, these options specify the number of bytes, lines or 512- byte blocks to display, instead of the bytes, lines or blocks from the beginning or end of the input from which to begin the display. The default for the - r option is to display all of the input. If more than a single file is specified, each file is preceded by a header consisting of the string ``==> XXX <=='' where XXX is the name of the file unless - q flag is specified. EXIT STATUS The tail utility exits 0 on success, and >0 if an error occurs. SEE ALSO cat(1), head(1), sed(1) STANDARDS The tail utility is expected to be a superset of the IEEE Std 1003.2-1992 (``POSIX.2'') specification. In particular, the - F, - b and - r options are extensions to that standard. The historic command line syntax of tail is supported by this implementa- tion. The only difference between this implementation and historic ver- sions of tail, once the command line syntax translation has been done, is that the - b, - c and - n options modify the - r option, i.e., ``- r - c 4'' displays the last 4 characters of the last line of the input, while the historic tail (using the historic syntax ``- 4cr'') would ignore the - c option and display the last 4 lines of the input. HISTORY A tail command appeared in PWB UNIX. BSD June 29, 2006 BSD

TR(1) BSD General Commands Manual TR(1) NAME tr - - translate characters SYNOPSIS tr [- Ccsu] string1 string2 tr [- Ccu] - - d string1 tr [- Ccu] - - s string1 tr [- Ccu] - - ds string1 string2 DESCRIPTION The tr utility copies the standard input to the standard output with sub- stitution or deletion of selected characters. The following options are available: - C - c - d - s - u Complement the set of characters in string1, that is ``- C ab'' includes every character except for `a' and `b'. Same as - C but complement the set of values in string1. Delete characters in string1 from the input. Squeeze multiple occurrences of the characters listed in the last operand (either string1 or string2) in the input into a single instance of the character. This occurs after all deletion and translation is completed. Guarantee that any output is unbuffered. In the first synopsis form, the characters in string1 are translated into the characters in string2 where the first character in string1 is trans- lated into the first character in string2 and so on. If string1 is longer than string2, the last character found in string2 is duplicated until string1 is exhausted. In the second synopsis form, the characters in string1 are deleted from the input. In the third synopsis form, the characters in string1 are compressed as described for the - s option. In the fourth synopsis form, the characters in string1 are deleted from the input, and the characters in string2 are compressed as described for the - s option. The following conventions can be used in string1 and string2 to specify sets of characters:

character Any character not described by one of the following conven- tions represents itself. \octal A backslash followed by 1, 2 or 3 octal digits represents a character with that encoded value. To follow an octal sequence with a digit as a character, left zero- pad the octal sequence to the full 3 octal digits. \character A backslash followed by certain special characters maps to special values. \a <alert character> \b <backspace> \f <form- feed> \n <newline> \r <carriage return> \t <tab> \v <vertical tab> A backslash followed by any other character maps to that char- acter. c- c For non- octal range endpoints represents the range of charac- ters between the range endpoints, inclusive, in ascending order, as defined by the collation sequence. If either or both of the range endpoints are octal sequences, it represents the range of specific coded values between the range end- points, inclusive. See the COMPATIBILITY section below for an important note regarding differences in the way the current implementation interprets range expressions differently from previous imple- mentations. [:class:] Represents all characters belonging to the defined character class. Class names are: alnum <alphanumeric characters> alpha <alphabetic characters> blank <whitespace characters> cntrl <control characters> digit <numeric characters> graph <graphic characters> ideogram <ideographic characters> lower <lower- case alphabetic characters> phonogram <phonographic characters> print <printable characters>

punct <punctuation characters> rune <valid characters> space <space characters> special <special characters> upper <upper- case characters> xdigit <hexadecimal characters> When ``[:lower:]'' appears in string1 and ``[:upper:]'' appears in the same relative position in string2, it repre- sents the characters pairs from the toupper mapping in the LCCTYPE category of the current locale. When ``[:upper:]'' appears in string1 and ``[:lower:]'' appears in the same rela- tive position in string2, it represents the characters pairs from the tolower mapping in the LCCTYPE category of the cur- rent locale. With the exception of case conversion, characters in the classes are in unspecified order. For specific information as to which ASCII characters are included in these classes, see ctype(3) and related manual pages. [=equiv=] Represents all characters belonging to the same equivalence class as equiv, ordered by their encoded values. [#*n] Represents n repeated occurrences of the character represented by #. This expression is only valid when it occurs in string2. If n is omitted or is zero, it is be interpreted as large enough to extend string2 sequence to the length of string1. If n has a leading zero, it is interpreted as an octal value, otherwise, it is interpreted as a decimal value. ENVIRONMENT The LANG, LCALL, LCCTYPE and LCCOLLATE environment variables affect the execution of ttrr as described in environ(7). EXIT STATUS The ttrr utility exits 0 on success, and >0 if an error occurs. EXAMPLES The following examples are shown as given to the shell: Create a list of the words in file1, one per line, where a word is taken to be a maximal string of letters. tr - cs "[:alpha:]" "\n" < file1 Translate the contents of file1 to upper- case.

tr "[:lower:]" "[:upper:]" < file1 (This should be preferred over the traditional UNIX idiom of ``tr a- z A- Z'', since it works correctly in all locales.) Strip out non- printable characters from file1. tr - cd "[:print:]" < file1 Remove diacritical marks from all accented variants of the letter `e': tr "[=e=]" "e" BSD July 23, 2004 BSD