first of all , directories created before and now i want to rename all of them !!
u just use simple mv to rename one directory !! how about 1000 directories with different number ????
why we use shell script . your work is like that to rename all directories manually !!!!!
i want to write shell script to grep for example 17 in all file names and change all of them to 16.50 and like that !!!
@mhs: Please do not leave people guessing. Show a representative sample of input, desired output, attempts at a solution and specify what OS and versions being used.
i wrote a simple code but i dont know how to expand that for this work
for example to change all 18 to 17.50
find . -type d | while read FILE
do
echo "$FILE" | grep 18 | sed 's/18/17.50/g'
done
and so on but my code does not make sense because 18 should be a counter from 1 to 23 and every time change in grep and sed to rename all directories .
awesome and brilliant . thx alot man .
could you explain a bit about i sed in your script i know what they do bu t i want to know about g;s \2/ and '\3/' .g;s/.*(\([0-9.]\+\)
sed 's/ //g;s/.*(\([0-9.]\+\)-\([0-9.]\+\))/\1 \2/;s/\./:/g'
and
sed 's/\(.*( *\)'$d1'\( *- *\)'$d2'\( *)\)/\1'$m1'\2'$m2'\3/'
---------- Post updated 09-16-13 at 01:49 AM ---------- Previous update was 09-15-13 at 10:34 PM ----------
i have a another problem with this kind of directories
Ok,
In first time, the script should work fine if you replace:
sed 's/ //g;s/.*(\([0-9.]\+\)-\([0-9.]\+\))/\1 \2/;s/\./:/g'
by
sed 's/ //g;s/.*(\([0-9.]\+\)-\([0-9.]\+\)).*/\1 \2/;s/\./:/g'
Explanation:
g ==> global, so with command s, the replace is global instead of only first occurence.
\(....\) => catch arguments and \1 reference argument 1,\2 argument 2,...
[0-9] => number 0 to 9
\+ => 1 or more the left character class so [0-9]\+ ==> 1 number or more number.