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
Remove first N bytes and last N bytes from a binary file on AIX. naveendronavall Shell Programming and Scripting 1 05-24-2008 11:06 AM
How to delete N bytes from the starting of the file from a C function??? jockey007 High Level Programming 2 11-15-2007 10:25 PM
Delete lines starting with XX or YY or ZZ or .... orno Shell Programming and Scripting 2 11-13-2007 05:33 PM
Copy only the initial 10 lines from a file to another jockey007 Shell Programming and Scripting 5 11-02-2007 02:05 PM
delete bytes from file Loriel Shell Programming and Scripting 6 04-13-2006 01:27 PM

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 11-15-2007
jockey007 jockey007 is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 18
How to delete initial N bytes from the starting of the file using sed?

I want to delete initial N bytes of a file using sed.
How can I do that?
  #2 (permalink)  
Old 11-16-2007
uvrakesh uvrakesh is offline
Registered User
  
 

Join Date: Dec 2005
Posts: 76
deleting some bytes

sed 's/^\(.\)\{11\}//g' forsed

This would help in deleting 11 bytes from the begining of a line, i assume u are not working on binary(I fear about endian issues).

This one is a generic u can adapt to your need, like for a line or more or specific line etc.
I am not whether this is what u require

Hope this helps
Regards,
RUV
  #3 (permalink)  
Old 11-19-2007
jockey007 jockey007 is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 18
Thanks Rakesh..
I'm not working with binary, so I believe this will help.
Wishes
Jay
  #4 (permalink)  
Old 11-19-2007
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,116
sed 's/^\(.\)\{11\}//g' forsed
will delete the first 11 characters from each line

sed '1s/^\(.\)\{11\}//g' forsed
will delete the first 11 characters from the first line but the first line must contain 11 or more characters

Ignoring line boundaries will be hard using sed. To ignore line boundaries and simply delete the first n characters you might want to consider switching to dd.
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:24 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