Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unhide hidden files in unix with sed and mv commands

i wonder if u could help me with fixing bash script which should unhide all hiden files in dir. Where is the problem?

param='.'
for file in $param*; do
mv $file $(echo $file | sed 's/^.\(.*\)/\1/')
done
exit
like image 598
Liudis Avatar asked Feb 15 '23 15:02

Liudis


1 Answers

This for loop should work:

export GLOBIGNORE=".:.."
for file in .*; do
   mv -n "$file" "${file#.}"
   # mv -n "$file" "${file:1}"
done

PS: Better to backup your files before doing a mass mv/rename

like image 108
anubhava Avatar answered Feb 24 '23 15:02

anubhava