Originally Posted by deli_conker
I'm not sure what the "if test -f" does. It seems like it looks into the current /home/i/ for a file named /etc/skel/j and if false (the -f switch?) if copies the file and then changes the ownership to the username matching the directory it is copying it into? Next j, next i.
What does the "fi" do?
"test -f" checks to see if $j is a file. This is to avoid trying to copy "." and ".." from /etc/skel. If you have any directories in /etc/skel that you want copied, then this will be a problem. And as bzbee said, the fi is end if (if spelled backwards).
Sorry, like I said, fairly new to linux and want to double check all of this before I mess it all up...
Before you change the echo's it is totally safe and won't do a thing. Maybe this will be more clear as to what it is doing:
for i in /home/* ; do (for j in /etc/skel/.* ; do if test -f $j;then echo cp $j $i;echo chown `basename $i` $i/`basename $j`;fi;done);done
Still does nothing, but echos the actual commands it would do. Remove the echos to make it actually do the work.