How to delete the First 3 characters from File-name using unix command

Please support our Shell Scripting advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Oct 2008
Posts: 26
Reputation: babusek is an unknown quantity at this point 
Solved Threads: 1
babusek babusek is offline Offline
Light Poster

How to delete the First 3 characters from File-name using unix command

 
0
  #1
Oct 17th, 2008
HI Folks
This is Question seems like scrap but look into this ..

I have several files in a directory(Ex:c:\dir\) now i have to remove the First 3 Characters from the File names in that directory. Using any unix command ..
Test Case 1:

C:\dir\
123file.txt
456newfile.mp3
57575unixfile.dat
trarruniing.txt

After the OPeration
now the Directory (c:\dir\) Should Contain
file.txt
newfile.mp3
unixfile.dat
trarruniing.txt
-----------------------------------------Thanks-----------------------------------------------------




Thanks
Last edited by babusek; Oct 17th, 2008 at 7:38 am.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 6
Reputation: noobguy is an unknown quantity at this point 
Solved Threads: 0
noobguy noobguy is offline Offline
Newbie Poster

Re: How to delete the First 3 characters from File-name using unix command

 
0
  #2
Oct 17th, 2008
Look at cut or awk or sed either of those would do it for you.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 26
Reputation: babusek is an unknown quantity at this point 
Solved Threads: 1
babusek babusek is offline Offline
Light Poster

Re: How to delete the First 3 characters from File-name using unix command

 
0
  #3
Oct 17th, 2008
Originally Posted by noobguy View Post
Look at cut or awk or sed either of those would do it for you.
Thank q,

see this code : sed 's/...\(.*\)//' file.txt

can change the file-names from a .txt file.
but i want to the Directory Files
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 399
Reputation: eggi will become famous soon enough eggi will become famous soon enough 
Solved Threads: 47
eggi eggi is offline Offline
Posting Whiz

Re: How to delete the First 3 characters from File-name using unix command

 
0
  #4
Oct 19th, 2008
Hey there,

If you want to do these en masse, you can either cd to the directory, or use a full path name and then apply that code generically to all the files in a for loop, while loop or using xargs, etc. That way your filename would be $x (or whatever you want to call your iterative variable) and not specifically the name of one file.

Hope that helps

, Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Shell Scripting Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC