If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > Pls. HELP : How can I remove the last line, last char using shell script

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-30-04, 23:30
wrcastro_ph wrcastro_ph is offline
Registered User
 
Join Date: Oct 2003
Posts: 5
Pls. HELP : How can I remove the last line, last char using shell script

I have a file that I need to edit using shell script. The original file looks like this :


'123456',
'234567',
'456789',

This should be the expected output :
'123456',
'234567',
'456789' <--- ( I just need to remove the (,) in the last line)

Do you guys have any idea on how to do this? using an SH or KSH shell script?
Reply With Quote
  #2 (permalink)  
Old 10-01-04, 01:08
Bob4480 Bob4480 is offline
Registered User
 
Join Date: Feb 2004
Location: Los Angeles, CA
Posts: 28
You could just use the tr command :

echo "456789," | tr ',' ' '

It would change the comma into a space. That would be a quick easy way to do it.
Reply With Quote
  #3 (permalink)  
Old 10-01-04, 01:44
wrcastro_ph wrcastro_ph is offline
Registered User
 
Join Date: Oct 2003
Posts: 5
Quote:
Originally Posted by Bob4480
You could just use the tr command :

echo "456789," | tr ',' ' '

It would change the comma into a space. That would be a quick easy way to do it.

But I only need to change the last line and not all of them.
Reply With Quote
  #4 (permalink)  
Old 10-01-04, 07:40
vgersh99 vgersh99 is offline
Registered User
 
Join Date: Apr 2004
Location: Boston, MA
Posts: 325
sed -e '$s/,$//' file
__________________
vlad
+-----------------------+
| #include <disclaimer.h> |
+-----------------------+
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On