|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
Can sed operate on a loop variable?
I'm sure this is an easy one but I can't seem to get it working. Given the following:
for oldName in `ls *.JPG` ;do newName=<confusion here. how to make sed perform 's/.JPG/_thumb.JPG/g' operation on $oldName> done Could someone show me how to make this work? Thanks Ken Last edited by ktoz : May 26th, 2003 at 01:20 PM. |
|
#2
|
|||
|
|||
|
Solved
Well that was fun...
Here's the solution I came up with to duplicate a group of files, selected by pattern into the current working directory. Hope this saves someone else some time. #!/bin/sh # change values of following two variables to whatever you want oldPattern=".JPG" newPattern="_copy.JPG" for tmp in `ls *.$oldPattern | sed "s/$oldPattern//g"`; do # create the new file touch $tmp$newPattern # copy contents of old file into new file cp $tmp$oldPattern $tmp$newPattern done Ken |
|
#3
|
|||
|
|||
|
Code:
for i in *.JPG; do
cp $i ${i%.JPG}_thumb.JPG
done
|
![]() |
| Viewing: Dev Shed Forums > Operating Systems > BSD Help > using egrep to rearrange file names |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|