tab seperated textfile and write each field in a variable
by Midyr from LinuxQuestions.org on (#5GZAT)
Hello,
I have a textfile with tab separate content.
The goal is, to insert fiels3 in some lines.
The first line is without field3.
filed6 contains a space, which makes the trouble
Code:F1 F2 F4 F5 F 6
F1 F2 F3 F4 F5 F 6My idea was, to do this with awk, and write each field in a variable but it dosen't work as expected.
Code:#!/bin/bash
while read
do
xy=($(awk -F '\t' '{print $1, $2, $3, $4, $5, $6}' ))
echo "Status; "${xy[0]}
echo "Start: "${xy[1]}
echo "End: "${xy[2]}
echo "Snr:: "${xy[3]}
echo "Ubknn: "${xy[4]}
echo "CN: "${xy[5]}
done < index.txtCode:
Status; F1
Start: F2
End: F3
Snr:: F4
Ubknn: F5
CN: FAs you can see, F6 is cuted after the space.
Any idea to this?
Thanks
Midyr


I have a textfile with tab separate content.
The goal is, to insert fiels3 in some lines.
The first line is without field3.
filed6 contains a space, which makes the trouble
Code:F1 F2 F4 F5 F 6
F1 F2 F3 F4 F5 F 6My idea was, to do this with awk, and write each field in a variable but it dosen't work as expected.
Code:#!/bin/bash
while read
do
xy=($(awk -F '\t' '{print $1, $2, $3, $4, $5, $6}' ))
echo "Status; "${xy[0]}
echo "Start: "${xy[1]}
echo "End: "${xy[2]}
echo "Snr:: "${xy[3]}
echo "Ubknn: "${xy[4]}
echo "CN: "${xy[5]}
done < index.txtCode:
Status; F1
Start: F2
End: F3
Snr:: F4
Ubknn: F5
CN: FAs you can see, F6 is cuted after the space.
Any idea to this?
Thanks
Midyr