![]() |
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 |
| Reducing Risk Versus Eliminating Risk | iBot | IT Security RSS | 0 | 05-29-2008 02:50 PM |
| UrgentPlease: compare 1 value with file values eliminating special characters | kittusri9 | Shell Programming and Scripting | 10 | 04-28-2008 04:51 AM |
| To split a string to obtain the words delimited by whitespaces | Sudhakar333 | Shell Programming and Scripting | 4 | 08-06-2007 02:26 PM |
| Moving Part of a field to another field using AWK | rjsha1 | Shell Programming and Scripting | 5 | 08-04-2006 05:39 AM |
| help me to remove the whitespaces between the lines ...urgent | kumar1 | Shell Programming and Scripting | 5 | 10-10-2005 08:51 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
I am reading a field from a file. This field have trailing whitespaces.
Does anyone knows, how to get rid of these whitespaces, at the time of reading? I know sed command as follows which removes whitespaces on a row - sed 's/[ \t]*$//' rows |
|
||||
|
Zazzybob,
The solution you have suggested removes spaces after reading the field from the file. I want solution something like, at the time of reading this field, there shouldnt be any trailing spaces. Let me make my problem statement clear by an illustration- Suppose I have a following file "tmpFile" : '1111,aaa ' '2222,bbbb ' excluding single quotes, those I have shown in order to signify the presence of trailing spaces at the end of the record. Now if I run following command, awk -F"," '{printf("%s:%s\n", $1,$2) }' tmpFile $2 field is read as- 'aaa ' 'bbbb ' Actually at the time of reading, I would like to read as - 'aaa' 'bbbb' I dont want to execute new command sed to strip off the trailing whitespaces, which I achieve with the following command - awk -F"," '{printf("%s:%s\n", $1,$2) }' tmpFile | sed 's/[ \t]*$//' Can we strip-off whitespaces at the time of reading? |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|