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
  #8 (permalink)  
Old 06-27-2008
Registered User
 

Join Date: Sep 2002
Posts: 9
Quote:
echo "123456789ABC" > testA && cat testA
My output is:

Quote:
123456789ABC
-----------------------------

Now run:

Quote:
cat testA |sed 's/^..........//' > testB
My output is:

Quote:
BC
in testB
Reply With Quote
Forum Sponsor
  #9 (permalink)  
Old 06-28-2008
Registered User
 

Join Date: Sep 2005
Posts: 3
For deleting first n number of chars

For deleting first n number of chars, instead of writing 'n' dots(.), following pattern can be used -

^.\{n\}
so the sed can be changed to

cat testA |sed 's/^.\{n\}//' > testB
Reply With Quote
  #10 (permalink)  
Old 07-07-2008
Registered User
 

Join Date: Jul 2008
Posts: 3
Quote:
Originally Posted by hemant29 View Post
For deleting first n number of chars, instead of writing 'n' dots(.), following pattern can be used -

^.\{n\}
so the sed can be changed to

cat testA |sed 's/^.\{n\}//' > testB

if you want to change all the file name as u required then this might help u

ls | while read file
do
file_req=`echo ${file} | sed 's/^.\{n\}//' `
mv ${file} ${file_req}
done
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 12:27 AM.


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

Content Relevant URLs by vBSEO 3.2.0