Sep 28, 2013
Find bugs with hearts
GNU coreutils basics
GNU Coreutils
This manual documents version 5.93 of the GNU core utilities, including the standard programs for text and file manipulation.Copyright © 1994, 1995, 1996, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".
- Introduction: Caveats, overview, and authors.
- Common options: Common options.
- Output of entire files: cat tac nl od
- Formatting file contents: fmt pr fold
- Output of parts of files: head tail split csplit
- Summarizing files: wc sum cksum md5sum sha1sum sha2
- Operating on sorted files: sort uniq comm ptx tsort
- Operating on fields within a line: cut paste join
- Operating on characters: tr expand unexpand
- Directory listing: ls dir vdir dircolors
- Basic operations: cp dd install mv rm shred
- Special file types: ln mkdir rmdir mkfifo mknod
- Changing file attributes: chgrp chmod chown touch
- Disk usage: df du stat sync
- Printing text: echo printf yes
- Conditions: false true test expr
- Redirection: tee
- File name manipulation: dirname basename pathchk
- Working context: pwd stty printenv tty
- User information: id logname whoami groups users who
- System context: date uname hostname
- Modified command invocation: chroot env nice nohup su
- Process control: kill
- Delaying: sleep
- Numeric operations: factor seq
- File permissions: Access modes.
- Date input formats: Specifying date strings.
- Opening the software toolbox: The software tools philosophy.
- GNU Free Documentation License: The license for this documentation.
- Index: General index.
--- The Detailed Node Listing ---
Common Options
- Exit status: Indicating program success or failure.
- Backup options: Backup options
- Block size: Block size
- Target directory: Target directory
- Trailing slashes: Trailing slashes
- Traversing symlinks: Traversing symlinks to directories
- Treating / specially: Treating / specially
- Standards conformance: Standards conformance
Output of entire files
- cat invocation: Concatenate and write files.
- tac invocation: Concatenate and write files in reverse.
- nl invocation: Number lines and write files.
- od invocation: Write files in octal or other formats.
Formatting file contents
- fmt invocation: Reformat paragraph text.
- pr invocation: Paginate or columnate files for printing.
- fold invocation: Wrap input lines to fit in specified width.
Output of parts of files
- head invocation: Output the first part of files.
- tail invocation: Output the last part of files.
- split invocation: Split a file into fixed-size pieces.
- csplit invocation: Split a file into context-determined pieces.
Summarizing files
- wc invocation: Print newline, word, and byte counts.
- sum invocation: Print checksum and block counts.
- cksum invocation: Print CRC checksum and byte counts.
- md5sum invocation: Print or check MD5 digests.
- sha1sum invocation: Print or check SHA-1 digests.
- sha2 utilities: Print or check SHA-2 digests.
Operating on sorted files
- sort invocation: Sort text files.
- uniq invocation: Uniquify files.
- comm invocation: Compare two sorted files line by line.
- ptx invocation: Produce a permuted index of file contents.
- tsort invocation: Topological sort.
ptx
: Produce permuted indexes - General options in ptx: Options which affect general program behavior.
- Charset selection in ptx: Underlying character set considerations.
- Input processing in ptx: Input fields, contexts, and keyword selection.
- Output formatting in ptx: Types of output format, and sizing the fields.
- Compatibility in ptx: The GNU extensions to
ptx
Operating on fields within a line
- cut invocation: Print selected parts of lines.
- paste invocation: Merge lines of files.
- join invocation: Join lines on a common field.
Operating on characters
- tr invocation: Translate, squeeze, and/or delete characters.
- expand invocation: Convert tabs to spaces.
- unexpand invocation: Convert spaces to tabs.
tr
: Translate, squeeze, and/or delete characters - Character sets: Specifying sets of characters.
- Translating: Changing one set of characters to another.
- Squeezing: Squeezing repeats and deleting.
Directory listing
- ls invocation: List directory contents
- dir invocation: Briefly list directory contents
- vdir invocation: Verbosely list directory contents
- dircolors invocation: Color setup for
ls
ls
: List directory contents - Which files are listed: Which files are listed
- What information is listed: What information is listed
- Sorting the output: Sorting the output
- More details about version sort: More details about version sort
- General output formatting: General output formatting
- Formatting the file names: Formatting the file names
Basic operations
- cp invocation: Copy files and directories
- dd invocation: Convert and copy a file
- install invocation: Copy files and set attributes
- mv invocation: Move (rename) files
- rm invocation: Remove files or directories
- shred invocation: Remove files more securely
Special file types
- link invocation: Make a hard link via the link syscall
- ln invocation: Make links between files
- mkdir invocation: Make directories
- mkfifo invocation: Make FIFOs (named pipes)
- mknod invocation: Make block or character special files
- readlink invocation: Print the referent of a symbolic link
- rmdir invocation: Remove empty directories
- unlink invocation: Remove files via unlink syscall
Changing file attributes
- chown invocation: Change file owner and group
- chgrp invocation: Change group ownership
- chmod invocation: Change access permissions
- touch invocation: Change file timestamps
Disk usage
- df invocation: Report file system disk space usage
- du invocation: Estimate file space usage
- stat invocation: Report file or file system status
- sync invocation: Synchronize data on disk with memory
Printing text
- echo invocation: Print a line of text
- printf invocation: Format and print data
- yes invocation: Print a string until interrupted
Conditions
- false invocation: Do nothing, unsuccessfully
- true invocation: Do nothing, successfully
- test invocation: Check file types and compare values
- expr invocation: Evaluate expressions
test
: Check file types and compare values - File type tests: File type tests
- Access permission tests: Access permission tests
- File characteristic tests: File characteristic tests
- String tests: String tests
- Numeric tests: Numeric tests
expr
: Evaluate expression - String expressions: + : match substr index length
- Numeric expressions: + - * / %
- Relations for expr: | & < <= = == != >= >
- Examples of expr: Examples of using
expr
Redirection
- tee invocation: Redirect output to multiple files
File name manipulation
- basename invocation: Strip directory and suffix from a file name
- dirname invocation: Strip non-directory suffix from a file name
- pathchk invocation: Check file name portability
Working context
- pwd invocation: Print working directory
- stty invocation: Print or change terminal characteristics
- printenv invocation: Print all or some environment variables
- tty invocation: Print file name of terminal on standard input
stty
: Print or change terminal characteristics - Control: Control settings
- Input: Input settings
- Output: Output settings
- Local: Local settings
- Combination: Combination settings
- Characters: Special characters
- Special: Special settings
User information
- id invocation: Print user identity
- logname invocation: Print current login name
- whoami invocation: Print effective user ID
- groups invocation: Print group names a user is in
- users invocation: Print login names of users currently logged in
- who invocation: Print who is currently logged in
System context
- date invocation: Print or set system date and time
- uname invocation: Print system information
- hostname invocation: Print or set system name
- hostid invocation: Print numeric host identifier.
date
: Print or set system date and time - Time conversion specifiers: %[HIklMNpPrRsSTXzZ]
- Date conversion specifiers: %[aAbBcCdDeFgGhjmuUVwWxyY]
- Literal conversion specifiers: %[%nt]
- Padding and other flags: Pad with zeroes, spaces, etc.
- Setting the time: Changing the system clock.
- Options for date: Instead of the current time.
- Examples of date: Examples.
Modified command invocation
- chroot invocation: Run a command with a different root directory
- env invocation: Run a command in a modified environment
- nice invocation: Run a command with modified niceness
- nohup invocation: Run a command immune to hangups
- su invocation: Run a command with substitute user and group ID
Process control
- kill invocation: Sending a signal to processes.
Delaying
- sleep invocation: Delay for a specified time
Numeric operations
- factor invocation: Print prime factors
- seq invocation: Print numeric sequences
File permissions
- Mode Structure: Structure of File Permissions
- Symbolic Modes: Mnemonic permissions representation
- Numeric Modes: Permissions as octal numbers
Date input formats
- General date syntax: Common rules.
- Calendar date items: 19 Dec 1994.
- Time of day items: 9:20pm.
- Time zone items: EST, PDT, GMT.
- Day of week items: Monday and others.
- Relative items in date strings: next tuesday, 2 years ago.
- Pure numbers in date strings: 19931219, 1440.
- Seconds since the Epoch: @1078100502.
- Specifying time zone rules: TZ="America/New_York", TZ="UTC0".
- Authors of get_date: Bellovin, Eggert, Salz, Berets, et al.
Opening the software toolbox
- Toolbox introduction: Toolbox introduction
- I/O redirection: I/O redirection
- The who command: The
who
command - The cut command: The
cut
command - The sort command: The
sort
command - The uniq command: The
uniq
command - Putting the tools together: Putting the tools together