![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| deleting a line but keeping the same file | laiko | UNIX for Dummies Questions & Answers | 2 | 05-13-2008 11:08 AM |
| Need to serach if a new line character exists on the last line in a file | sunilbm78 | UNIX for Dummies Questions & Answers | 10 | 02-29-2008 11:15 AM |
| Deleting Junks at the end of each line in a file | dave_nithis | UNIX Desktop for Dummies Questions & Answers | 5 | 10-04-2007 11:51 PM |
| Problem deleting file with special character | hart1165 | UNIX for Dummies Questions & Answers | 2 | 12-07-2005 08:29 AM |
| Deleting end line spaces for along file | osymad | Shell Programming and Scripting | 3 | 02-23-2005 10:56 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Deleting end of line $ character in file
Hi, I've got a file where in the middle of the record is a $ end of line character, visible only when I open the file in vi and do :set list. How to I get rid of the character in the middle and keep it at the end. The middle $ character always appears after SW, so that can be used to tag it.
Normal row - Field 1, Field2,Field3, Field 4$ Bad row - Field 1, Field2SW$, Field3, Field 4$ |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
This script will join the lines end with ','
awk '{ if(substr($0,length)==",") printf("%s ",$0); else print }' filename
|
|
#3
|
|||
|
|||
|
Hi Ranjithpr;
I'm not getting the results I want... is there someway to tell the script to remove the $ character immediately after the SW and combine the two lines together. Thanks so much for helping out. |
|
#4
|
|||
|
|||
|
Do the following within the file to remove SW$ .
:g/SW\$/s/// Then you can apply rangithpr's suggestion to give you a final fix awk '{ if(substr($0,length)==",") printf("%s ",$0); else print }' filename Last edited by jxh461; 01-08-2008 at 10:24 AM. |
|||
| Google The UNIX and Linux Forums |