shell variables advanced

Reborg's solution works, thanks.
Edidataguy yes i type it properly (use copy and paste) but did not work, neither the

ls *track* | sed 's/.*\(track.*$\)/cp "&" \1/' 

did not work.
But can somebody explain why my bash script with for did not work ? I am trying to learn something new in bash not ksh. thanks

Change the line as follows:

 echo $x | sed -ne 's/\([0-9]\{2\}\) - .* - .*[0-9]\{3\}\.mp3/track\1.mp3/gp'

OK I made it!

#!/bin/bash
FS=$'\n'
for x  in *.mp3
do
 var="`echo -ne $x | sed -ne 's/\([0-9]\{2\}\) - .* - .*[0-9]\{3\}\.mp3/track\1.mp3/gp' `"
 cp "$x" "$var"
done
unset IFS

but is stil strange of me why

var="`echo -ne $x | sed -ne 's/\([0-9]\{2\}\) - .* - .*[0-9]\{3\}\.mp3/track\1.mp3/gp' 
is not the same thing like i did before
var="`sed -ne 's/\([0-9]\{2\}\) - .* - .*[0-9]\{3\}\.mp3/track\1.mp3/gp' "$x"`"

---------- Post updated at 04:25 PM ---------- Previous update was at 04:23 PM ----------

yes you right :slight_smile: i did not read your last post, we both discovered the same thing :smiley:

% echo $IFS | od -c
0000000 \n
0000001

echo "$IFS" | od -c