The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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




Thread: file renaming
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #5 (permalink)  
Old 10-13-2008
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,361
Quote:
Originally Posted by Franklin52 View Post
Code:
ls -1 iq*.bin | awk '{print "mv "$0" "$1"_"$5"_"$7"_"$9}'

There's no need for -1 when the output of ls is not going to a terminal. In fact, there's no need for ls at all:

Code:
printf "%s\n" iq*.bin | awk '{printf  "mv \"$0\" \"%s_%s_%s_%s\"\n", $1, $5, $7, $9}'
(printf is a shell builtin in all the major shells.)