Search

expand: To convert a tab space to space characters

expand: Command used to convert the tab space to separate space characters.

Example:

Let us say we we have a file "temp" with the following contents.

temp:



In each line we have one tab space, which is equivalent to 8 space characters. To convert this one tab space to 8 space characters we can run the command expand on the file.



The new file "temp_1" looks the same as the file "temp" but if we open the file to edit it, we will encounter 8 space characters instead of tab on every line.

To change the number of space characters from 8 to any number of our choice we can use the option "-t".



We can see that the tab has been replaced by single space. The number that you specify after "-t" will be the number of spaces that will put instead of the tab space.

We can also restrict the command to work only at the beginning of a file by passing the option "-i"

Example :

Let us modify the file temp and add a tab at the beginning of the first line.

temp:



Now use expand on the file along with option "-i"



We can see that only the tab at the beginning of the first line has been removed,but the rest of the tabs are intact.

Follow by Email