Computer Hope

Other Pages

Home
Site map
Computer help

Dictionary
News
Q&A
What's new

Tools

E-mail this page
Print Preview
Edit this page



 

Linux / Unix expand and unexpand

Quick links

About expand and unexpand
Syntax
Examples
Related commands
Linux / Unix main page

About expand and unexpand

Expand copies files (or the standard input) to the standard output, with TAB characters expanded to SPACE characters. BACKSPACE characters are preserved into the output and decrement the column count for TAB calculations. expand is useful for pre-processing character files (before sorting, looking at specific columns, and so forth) that contain TAB characters.

Syntax

expand [ -t tablist ] [-tabstop] [-tab1, tab2,. . ., tabn] [ file ... ]

unexpand [ -a ] [ -t tablist ] [ file ... ]

-t tablist Specify the tab stops. The argument tablist must consist of a single positive decimal integer or multiple positive decimal integers, separated by blank characters or commas, in ascending order. If a single number is given, tabs will be set tablist column positions apart instead of the default 8. If multiple numbers are given, the tabs will be set at those specific column positions. 

Each tab-stop position N must be an integer value greater than zero, and the list must be in strictly ascending order. This is taken to mean that, from the start of a line of output, tabbing to position N causes the next character output to be in the (N+1)th column position on that line. 

In the event of expand having to process a tab character at a position beyond the last of those specified in a multiple tab-stop list, the tab character is replaced by a single space character in the output.

tabstop Specify as a single argument, sets TAB characters tabstop SPACE characters apart instead of the default 8.
tab1, tab2,..., tabn Set TAB characters at the columns specified by -tab1,tab2,...,tabn
-a Insert TAB characters when replacing a run of two or more SPACE characters would produce a smaller output file.
file The path name of a text file to be used as input.

Examples

expand myfile.txt

Would expand the file myfile.txt

expand -8 myfile.txt > myfile2.txt

Converts the tabs in the file myfile.txt to 8 spaces instead of a single tab.

Related commands

tabs

 

Index

Category:
Linux / Unix

Companies:
Click here

Related Pages:

 

Resolved

Were you able to locate the answer to your questions?

Home - Computer help - Contact - Dictionary - Links
Link to Computer Hope - Bookmark Computer Hope