The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

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 11:08 AM
Deleting lines above a certain line eltinator Shell Programming and Scripting 3 10-11-2007 11:29 AM
Deleting First Two Characters On Each Line scotbuff Shell Programming and Scripting 5 12-15-2006 09:03 PM
Checking the last line and deleting srivsn Shell Programming and Scripting 3 12-13-2005 10:04 AM
Deleting UNIX End of Line Chachracter \000 uchachra UNIX for Advanced & Expert Users 3 12-22-2004 05:56 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-23-2008
Registered User
 

Join Date: Sep 2007
Posts: 13
Stumble this Post!
Deleting First 10 letters in a line

Hi,

Could any one of you let me know any simple Unix command for deleting first 10 letters of first line in unix?

Eg: 123456789ABC --Input

ABC--Output

Thanks

Sue
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 06-23-2008
Smiling Dragon's Avatar
Disorganised User
 
Join Date: Nov 2007
Location: New Zealand
Posts: 709
Stumble this Post!
Post

Quote:
Originally Posted by pyaranoid View Post
Could any one of you let me know any simple Unix command for deleting first 10 letters of first line in unix?

Eg: 123456789ABC --Input

ABC--Output
You mean CB? (1-9 is 9 chars, not 10)
Code:
echo "123456789ABC" | sed 's/^..........//'
Reply With Quote
  #3 (permalink)  
Old 06-24-2008
Registered User
 

Join Date: Sep 2007
Posts: 13
Stumble this Post!
Hi,

Thank you. It worked when i use the code provided by you. Suppose if i need to use that code for a file and if i want to replace the input file with the first 10 letters removed, how can i do that?

Thanks

Sue
Reply With Quote
  #4 (permalink)  
Old 06-24-2008
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,844
Stumble this Post!
Code:
sed 's/^..........//' inputfile > newfile
Reply With Quote
  #5 (permalink)  
Old 06-25-2008
Registered User
 

Join Date: Sep 2007
Posts: 13
Stumble this Post!
Hi,

If i do like that, i am getting an output file with 0 bytes.

Please adivice me what can be done to resolve this.

Thanks

Sue
Reply With Quote
  #6 (permalink)  
Old 06-25-2008
Registered User
 

Join Date: Feb 2007
Posts: 11
Stumble this Post!
Quote:
Originally Posted by Smiling Dragon View Post
Code:
echo "123456789ABC" | sed 's/^..........//'
Hmm, but that is not very flexible, imagine the next problem being to remove the first 43 characters. How about:
Code:
echo "123456789ABC" | cut -c11-
Reply With Quote
  #7 (permalink)  
Old 06-27-2008
Registered User
 

Join Date: Sep 2007
Posts: 13
Stumble this Post!
Hi,

The following command gave me the correct results:

cut -c39- In_Put.txt > Out_Put.txt


Thanks Once again,

Sue

Last edited by pyaranoid; 06-27-2008 at 08:04 AM.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 09:26 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0