The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

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 02:08 PM
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 02:15 PM
Deleting Junks at the end of each line in a file dave_nithis UNIX Desktop for Dummies Questions & Answers 5 10-05-2007 02:51 AM
Problem deleting file with special character hart1165 UNIX for Dummies Questions & Answers 2 12-07-2005 11:29 AM
Deleting end line spaces for along file osymad Shell Programming and Scripting 3 02-23-2005 01:56 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-08-2008
bwrynz1 bwrynz1 is offline
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$
  #2 (permalink)  
Old 01-08-2008
ranjithpr ranjithpr is offline
Registered User
  
 

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

awk '{ if(substr($0,length)==",") printf("%s ",$0); else print }' filename
  #3 (permalink)  
Old 01-08-2008
bwrynz1 bwrynz1 is offline
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.
  #4 (permalink)  
Old 01-08-2008
jxh461 jxh461 is offline
Registered User
  
 

Join Date: Jun 2002
Posts: 49
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 01:24 PM..
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:11 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0