The input was a list of files, the output should be mv commands to rename the files. The sed solution is a little bit complicated, because there is no easy way to save the original file name.
Your one-liner does not create these 'mv' commands files, as was the requirement
This modification of your script does produce them:
Code:
{
orig = $1
sub(/-/,"_")
printf("mv %s %s\n", orig, $1) ;
}
Saved as 'ren_awk' you use it this way:
Code:
$ awk -f ren_awk tmp
mv NOW/latest-pkg NOW/latest_pkg
mv NOW/latest-pkg-calyx NOW/latest_pkg-calyx
mv NOW/latest-pkg-erlangen NOW/latest_pkg-erlangen
mv NOW/latest-pkg-esat NOW/latest_pkg-esat
mv NOW/latest-pkg-plig NOW/latest_pkg-plig
mv NOW/latest-pkg-stacken NOW/latest_pkg-stacken