The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #7 (permalink)  
Old 01-05-2009
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,540
Quote:
Originally Posted by freizl View Post
Assuming the "ABC20090102" string is fixed length.
And I'm using sh shell.

Code:
ls -1 *.txt | awk '{print "mv", $1, substr($1,12) }' | sh
it is also not necessary to use ls and sh , by making use of FILENAME variable
Code:
awk '{ system("mv " FILENAME" " substr(FILENAME,1,12) )}' ABC*.txt
not tested.