Linux/Unix Shell Scripting - Alguien me corrige este script?

 
Vista:
sin imagen de perfil

Alguien me corrige este script?

Publicado por Tomas (13 intervenciones) el 04/03/2014 18:48:16
Me da error inesperado de sintaxis cerca del done. Linea 8(ultima)
1
2
3
4
5
6
7
8
#!/bin/bash
 
while read line ; do
echo "$line"
if [ "$line" -gt "0" ] ;then echo "$line" >> /home/alum1/f2.txt
elif [ "$line" -lt "0" ] ;then echo "$line" >> /home/alum1/f3.txt
if [ "$line" -eq "0" ] ;then echo "$line" >> /home/alum1/f2.txt
done < /home/alum1/f1.txt
hay un espacio al abrir y cerrar corchetes, y antes del ";then" por si no se ve bien.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de xve
Val: 104
Oro
Ha mantenido su posición en Linux/Unix Shell Scripting (en relación al último mes)
Gráfica de Linux/Unix Shell Scripting

Alguien me corrige este script?

Publicado por xve (309 intervenciones) el 04/03/2014 19:30:55
Hola Tomas, todo if tiene que llevar su fi
Cierra los dos if's... algo así:
1
2
3
4
5
6
7
8
9
10
#!/bin/bash
 
while read line ; do
echo "$line"
if [ "$line" -gt "0" ] ;then echo "$line" >> /home/alum1/f2.txt
elif [ "$line" -lt "0" ] ;then echo "$line" >> /home/alum1/f3.txt
fi
if [ "$line" -eq "0" ] ;then echo "$line" >> /home/alum1/f2.txt
fi
done < /home/alum1/f1.txt

Coméntanos, ok?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Alguien me corrige este script?

Publicado por Tom (361 intervenciones) el 05/03/2014 17:45:29
Por cierto, si no es mayor ni menor, es que es igual ;)

1
2
3
4
5
6
7
8
9
while read line
do
	if [ "$line" -lt "0" ]
	then
		echo "$line" >> /home/alum1/f3.txt
	else
		echo "$line" >> /home/alum1/f2.txt
	fi
done < /home/alum1/f1.txt
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil

Alguien me corrige este script?

Publicado por Tomas (13 intervenciones) el 07/03/2014 16:18:09
funciona! Nose porque antes no funcionaba. Solo cambie la posición de los fi como has puesto arriba(abajo de la condición), y al -eq "0", lo guarde en f4.txt
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar