The UNIX and Linux Forums  

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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
back to back printing in UNIX amirthraj_12 AIX 3 05-06-2008 04:42 AM
Back-to-Back Connection using HBAs aldowsary IP Networking 2 11-12-2007 03:43 PM
How to print two sql query outputs side by side in excel prasee Shell Programming and Scripting 6 09-07-2007 11:20 PM
File to Array and Back. Boucho High Level Programming 1 02-14-2006 08:32 AM
Having a Unix system installed side to side with Windows? Pcslider UNIX for Dummies Questions & Answers 14 01-29-2002 03:21 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 07-28-2008
Registered User
 

Join Date: Jul 2008
Posts: 15
How to cut a file name from back side

Hi
I have to delete 18 characters from my file names from back side.

i mean if file name is abcde123456

then i have to delete 6 characters from back and i need file name as abcde.

Please help
Reply With Quote
Forum Sponsor
  #2  
Old 07-28-2008
Registered User
 

Join Date: Aug 2007
Location: Bangalore
Posts: 288
Code:
file=abcdefg123456
newfile=${var%??????}
echo $newfile
abcdefg
Thanks
namish
Reply With Quote
  #3  
Old 07-28-2008
Moderator
 

Join Date: Sep 2007
Location: Germany
Posts: 958
with sed

Code:
sed 's/.\{6\}$//g'
Reply With Quote
  #4  
Old 07-28-2008
Registered User
 

Join Date: Sep 2006
Posts: 1,580
If you have GNU cut
Code:
echo abcde123456 | cut -c6- --complement
Reply With Quote
  #5  
Old 07-28-2008
Registered User
 

Join Date: Jul 2008
Posts: 15
it worked...

thank you so much
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 01:48 PM.


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 Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0