Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

command line pattern and $ vars

Status
Not open for further replies.

simanek

Programmer
Jan 19, 2001
137
US
hi all,
I"m trying to mv several files from name.new to name.old. In other words, I have a bunch of files with the .new extension that I want to copy to a file of the same name with a .old extension. I'm doing this in ksh. I thought I could simply do a mv *.new $1.old but that just doesn't work. Any help would be appreciated. Mike
~~~~
simanek@uiuc.edu
"It's a Swingline!"
~~~~
 
Try this:

#!/usr/bin/ksh

for item in *.new
do
mv $item ${item%.new}.old
done

Just something to think about ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top