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 Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Truncate multiple file extensions prvnrk Shell Programming and Scripting 12 04-04-2008 10:20 AM
truncate file script is not working mvenkat_in Shell Programming and Scripting 3 10-24-2007 01:01 AM
Truncate File contain rinku Shell Programming and Scripting 2 05-30-2007 06:43 AM
how to truncate a large (8 GB) file kotasateesh Shell Programming and Scripting 1 07-05-2006 01:57 AM
Truncate what is It? rocker40 UNIX for Dummies Questions & Answers 2 10-11-2003 07:40 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 03-04-2008
Gwailo88 Gwailo88 is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 2
Truncate last <n> characters from a file

I am trying to concatenate 2 files, but before concatenation, I would like to strip off the final character from the first file.

The final character is a form feed (ascii 012 / hex 0C) and there will be an unknown number of these characters in the file. It is only the very last one which I want to remove.
  #2 (permalink)  
Old 03-05-2008
Gwailo88 Gwailo88 is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 2
Lightbulb One Solution

Think I've found my fix unless someone has a more elegant solution...

# Set Split Size 1 Byte Less than Total
((SPLITSIZE=`wc -m $SRCFILE | awk '{print $1}'` - 1))
# Split File
split -b $SPLITSIZE $SRCFILE $SRCFILE.
# Concatenate Header with Second File
cat $SRCFILE.aa $SCNDFILE > mergefile.pcl
# Clean up detritus
rm $SRCFILE*.*
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 10:41 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