#!/bin/ksh
for i in .[^.]*
do
echo mv "$i" "${i#.}"
done
I use the Korn shell. You can use any POSIX conforming shell by changing /bin/ksh in #!/bin/ksh to the pathname of the conforming shell you want to use. (And, remove the echo , when you have convinced yourself that the script correctly selects the files you want to move.)
Assuming all your file names are more than 2 char length:
#!/bin/ksh
printf "%s\n" .* | while read h_file # Reading all hidden file names
do
r_file=$( echo "$h_file" | sed 's#^\.##g' ) # Removing the leading period sign
if [ ${#r_file} -gt 2 ] # Checking if length is greater than 2
then
echo "mv $h_file $r_file"
fi
done
Note: Remove the highlighted echo if the output is as expected.
I'm glad that bipinajith's script worked for you, but I'd still like to know why ksh or bash on AIX didn't work for you. What shell did you use? What happens if you run the command:
ksh NameOfFileContainingMyScript
instead of:
~/mvhidden
Note that ~/mvhidden runs a command found in your home directory; did you by any chance have different versions of mvhidden in different directories?
Ouch. Yes. I must have been asleep when I made that suggestion. The pattern I suggested used regular expression syntax; not pathname expansion syntax. I don't know why it did what I expected on OS X.
There are two ksh standards, the old one (I forget what the year was, 1985?), and the new one - ksh93 - from 1993 obviously.
Perhaps if if added "hash-bang" ksh93 to the first script it will work the same as on OS-X.