eXtropia: the open web technology company
Technology | Support | Tutorials | Development | About Us | Users | Contact Us
Resources
 ::   Tutorials
 ::   Presentations
Perl & CGI tutorials
 ::   Intro to Perl/CGI and HTML Forms
 ::   Intro to Windows Perl
 ::   Intro to Perl 5
 ::   Intro to Perl
 ::   Intro to Perl Taint mode
 ::   Sherlock Holmes and the Case of the Broken CGI Script
 ::   Writing COM Components in Perl

Java tutorials
 ::   Intro to Java
 ::   Cross Browser Java

Misc technical tutorials
 ::   Intro to The Web Application Development Environment
 ::   Introduction to XML
 ::   Intro to Web Design
 ::   Intro to Web Security
 ::   Databases for Web Developers
 ::   UNIX for Web Developers
 ::   Intro to Adobe Photoshop
 ::   Web Programming 101
 ::   Introduction to Microsoft DNA

Misc non-technical tutorials
 ::   Misc Technopreneurship Docs
 ::   What is a Webmaster?
 ::   What is the open source business model?
 ::   Technical writing
 ::   Small and mid-sized businesses on the Web

Offsite tutorials
 ::   ISAPI Perl Primer
 ::   Serving up web server basics
 ::   Introduction to Java (Parts 1 and 2) in Slovak

 

Introduction to UNIX for Web Developers
The "cut" Utility  
The cut utility allows you to cut a specified bit of data from a file. The most common usage is to split delimited lines such that the command returns a given field for each row.

The "cut" utility follows the basic syntax shown below:

cut -c[character_position] filelist
or
cut -f[fields] -d[field separator] filelist

Consider the cut operation applied to the password file in which we direct the utility to return the 3rd field as delimited by the colon character.

[Spacer]
[cut Example]

[Spacer]

Options Description
-c[character_position] Specifies the character positions to cut out. It can be a comma delimited list, a dash specified range, or both such as 1,2,3 6-10,18
-f[fields] Specifies the fields that should be cut out provided you also specify a delimiter. this does not work with the -c option and vice versa.
-d[delimiter] The character that delimits fields
-s Specifies that if the specified delimiter does not appear in the line, that the line should not be included im the cut.

Below are some more examples of using cut. Notice that by default cut expects a tab character or space as a delimiter so no delimiter need be specified if your file is already delimited by a space character or tab.

[cut Example]

Previous | Next | Table of Contents