![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How can i replace a character with blank space? | rollthecoin | AIX | 8 | 04-22-2008 09:55 AM |
| [bash] Check if variable is set or blank | noratx | Shell Programming and Scripting | 1 | 03-28-2008 09:42 AM |
| how to check weather file is blank or not? | jaydeep_sadaria | Shell Programming and Scripting | 5 | 12-15-2007 08:35 AM |
| how to check first character in var's value. | yongho | UNIX for Dummies Questions & Answers | 7 | 07-01-2005 12:22 PM |
| awk: How to check if field is blank? | yongho | Shell Programming and Scripting | 7 | 06-09-2005 12:35 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
check for the first character to be blank
I'm having a problem when the first line or first character of a file is blank. I need to get rid of both of them when they occur but don't want to delete the line. Does anyone have any suggestions?
|
|
||||
|
Code:
sed 's/^ *//' file1|sed '/^$/d'|sed '/^ $/d' > file2 # cat file1 Line 2 Line 3 Line 4 # cat file2 Line 2 Line 3 Line 4 # im sure there is a way to make it look prettier then invokeing sed 3x but it works. |
|
||||
|
Quote:
|
|
||||
|
Thanks oombera and optimus...
both of the solutions each of you gave worked like a charm. I tried sometime similar to the end of the line as well.. with some mixed success.Thanks again for your assistance.... and if you have any suggestions on how to get rid of the space at the end of the line, let me know. Harold |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|