#!/bin/bash homedir="/home/$USER/" bindir=$homedir"/bin/" #Creamos el $bindir si no existe if [ ! -d $bindir ]; then mkdir $bindir if [ $? -ne 0 ]; then #Si no podemos crearlo, salimos con error. echo "ERROR: no se puede crear $bindir." exit 1 fi fi for fich in $(ls $homedir); do #Si el archivo es ejecutable y no es un directorio, lo movemos a $bindir. if [ ! -d $fich ] && [ -x $fich ]; then echo "Moviendo $fich a $bindir/$fich." mv $fich $bindir"/"$fich if [ $? -ne 0 ]; then echo "ERROR: no se ha podido mover $fich." fi fi done