![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| remove spaces btw | tjmannonline | UNIX for Dummies Questions & Answers | 7 | 05-26-2008 02:35 AM |
| Remove spaces from columns | jacks | Shell Programming and Scripting | 2 | 01-18-2008 10:08 AM |
| How to remove trailing spaces | mahek_bedi | UNIX for Dummies Questions & Answers | 2 | 08-10-2007 07:21 AM |
| how to remove spaces in a string using sed. | radhika | Shell Programming and Scripting | 4 | 06-02-2005 03:00 PM |
| removing trailing spaces of a particular column in a file | rooh | UNIX for Dummies Questions & Answers | 2 | 01-12-2002 11:34 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
|||||
|
Quote:
I'll check it when i'll be in office. Meanwhile would you pls. explain the code to me? Regards, Tayyab |
|
||||
|
The block within { ... } is executed for every line of the file.
substr($0,1,27) extracts a substring of $0, the line just read, starting at character number 1 and continuing for 27 characters. gsub( / /, "", col1 ) globally substitutes for each space in col1 the empty string; i.e., it removes all spaces. When the resulting line is printed, we have to make sure that the data we changed is still 27 columns wide. Since each comma in the print statement provides 1 space, we subtract the size of col1 from 25 instead of from 27. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|