I have to create, from each file that pass me by parameter, a file with each line of the form filename . numeroNLaLinea . The code that I thought is the following:
#!/bin/bash
for file in $@
do
i=0
if [[ -s $file ]]
then
echo $file | while read line
do
(( i++ ))
echo $line >> /var/log/FicherosDeTexto/$file.$i
done
else
touch /var/log/FicherosDeTexto/$file.$i
fi
done
The fact is that when creating each of the files I get the following errors:
touch: no se puede efectuar 'touch' sobre «/var/log/FicherosDeTexto/FicherosAyuda/Vacio.0»: No existe el fichero o el directorio
./act1.sh: línea 11: /var/log/FicherosDeTexto/FicherosAyuda/Archivo3lineas.1: No existe el fichero o el directorio