jueves, 8 de noviembre de 2018

How to read a file into a variable in shell?

How to read a file into a variable in shell?


Hi!

I have a needed to read a file with some columns and separte each one, and after do that i need to make a script that create a folder and move on every single file on it.

The first thing i have to do for this test, is create a file with some content like this:

Pepe tiene: 23
Paula tiene: 34
Juan tiene: 27
Maria tiene: 54
Federico tiene: 50
Pablo tiene: 32
Sonia tiene: 33


Next i 

#!/bin/bash
#
#test
#
while read line;do
file="$(echo ${line} | cut -d':' -f1)";
edad="$(echo ${line} | cut -d':' -f2)";
echo ${archivo} : ${edad};
done < archivo_test.txt


http://www.forosdelweb.com/f41/script-extraer-lineas-fichero-mostrarlas-1089860/

No hay comentarios:

Publicar un comentario

  Installing Redis-x64-3.2.100 on Windows and Running Redis Server https://medium.com/@kasunprageethdissanayake/installing-redis-x64-3-2-100...