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 > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
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
removing a character and addending to end in each line in a file arunkumar_mca UNIX for Dummies Questions & Answers 5 01-30-2008 12:48 AM
removing new line character ammu Shell Programming and Scripting 2 01-15-2008 10:12 AM
Removing character from list line (at the end) malaymaru Shell Programming and Scripting 2 11-28-2007 08:05 AM
Removing a particular line from a text file sendhilmani123 Shell Programming and Scripting 5 05-31-2006 08:32 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-18-2005
cjhancock cjhancock is offline
Registered User
  
 

Join Date: Feb 2005
Posts: 15
Removing last character from each line of file

How can I remove the last character from each line of a file?

This must be done without "funny" characters, as I want to transfer the code to/from Windows.

Any ideas?
  #2 (permalink)  
Old 02-18-2005
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,121
sed -e 's/\(.*\).$/\1/g' file

As it's been outlined in the thread, transfer/ftp your files in ASCII mode.
  #3 (permalink)  
Old 02-18-2005
cjhancock cjhancock is offline
Registered User
  
 

Join Date: Feb 2005
Posts: 15
Not so simple

Trouble is, I'm transferring a zip file containing binary and ascii files - I FTP the zip file as binary, then use unzip - so I'm in the lap of the gods...

Thanks
  #4 (permalink)  
Old 02-18-2005
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,121
do you have TWO files to transfer or ONE zip?

if you have 2, transfer zip in binary and others in ascii.

AM I misisng the point here?
  #5 (permalink)  
Old 02-18-2005
cjhancock cjhancock is offline
Registered User
  
 

Join Date: Feb 2005
Posts: 15
Missing the point

I've got ONE zip file containing both binary and ASCII files. I transfer it as binary, then unzip it. If I try to unzip using the -a switch, one of the binary files gets interpreted as ASCII which is a bigger problem.

Any clearer? I really appreciate your help
  #6 (permalink)  
Old 02-18-2005
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,121
and if you use '-b' or '-B'?
I'm not a real guru when it comes to 'unzip' - just reading 'man unzip'.
  #7 (permalink)  
Old 03-10-2005
daytripper1021 daytripper1021 is offline
Registered User
  
 

Join Date: Mar 2005
Posts: 12
getting the last character of a line?

Quote:
Originally Posted by vgersh99
sed -e 's/\(.*\).$/\1/g' file

As it's been outlined in the thread, transfer/ftp your files in ASCII mode.
Hi,

Can u rephrase the sed-command above such that it will display only the last character of the line? For example: if the line is:

hello world!

It will only display:

!

Appreciate your help.

Thanks.
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 01:17 AM.


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