home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam    

UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 35.14 Cutting Columns or Fields with cut Chapter 35
You Can't Quite Call This Editing
Next: 35.16 Make Columns Automatically with cols
 

35.15 Cutting Columns with colrm

BSD's (somewhat limited) alternative to cut ( 35.14 ) is colrm .

It can cut only by column position, not by field. All you have to give it is a starting column position and an optional ending position. The text is read from standard input. ( colrm can't read files directly; redirect input with < or | ( 13.1 ) .)

If you give just one column number, all columns from that position to the end of the line are removed. With two column number arguments, all columns between the starting column position and the ending position, inclusive, are removed.

The following command outputs just the permissions (columns 1 to 10) and filenames (columns 45 to the end of the line, including the space before names) from fixed-width ls -l output ( 22.2 ) . (Some versions of ls -l adjust column widths. If yours does, colrm and cut won't help; try awk ( 33.11 ) .)

% 

ls -l | colrm 11 44


drwxr-xr-x manpages
-rw-r--r-- misc.Z
-rwxr-xr-x myhead

The following command will remove the remote hostname, if any, that starts at column 33 of who ( 51.4 ) output:

% 

who | colrm 33

- JP , TOR


Previous: 35.14 Cutting Columns or Fields with cut UNIX Power Tools Next: 35.16 Make Columns Automatically with cols
35.14 Cutting Columns or Fields with cut Book Index 35.16 Make Columns Automatically with cols

The UNIX CD Bookshelf Navigation The UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System










??????????????@Mail.ru