The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
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

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 01-08-2008
Registered User
 

Join Date: Jan 2008
Posts: 6
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$
Reply With Quote
Forum Sponsor
  #2  
Old 01-08-2008
Registered User
 

Join Date: Nov 2007
Posts: 85
This script will join the lines end with ','

awk '{ if(substr($0,length)==",") printf("%s ",$0); else print }' filename
Reply With Quote
  #3  
Old 01-08-2008
Registered User
 

Join Date: Jan 2008
Posts: 6
Smile Deleting $ end of line character from middle of line

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.
Reply With Quote
  #4  
Old 01-08-2008
Registered User
 

Join Date: Jun 2002
Posts: 36
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.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 09:23 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0