Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

Bash Script Looping all the time

$
0
0
Hello,

I have a database file, named data.txt, and a shell script (convert.sh) to convert data.txt from columns to row. Output file name will be column_to_row.txt
In this example data.txt has only four rows.

Format of data.txt is:
info name surname telefon_nr

Data.txt
Code:

info boris vian 0012345678
info kristaq skowronska 009876567
info emmanuel kant 00987654321

convert.sh
Code:

#!/bin/bash
while read -r COL1 COL2 COL3 COL4
sleep 2
do
echo "
[info_card]
name                          = "$COL2"
surname                      = "$COL3"
phone_nr                    = "$COL4" "
done < Data.txt
exit 0

To run convert.sh, i enter below command in terminal:

Code:

./convert.sh > column_to_row.txt
When I run it, script is not ending until i press ctrl+c. After processing four lines, it keeps running. How may I stop this script when all lines existing in data.txt file are processed ?


Many Thanks
Boris

Viewing all articles
Browse latest Browse all 16232

Latest Images

Trending Articles



Latest Images