Shell script to read lines in a text file and filter user data Shell Programming and Scripting

sxsaaas

Hi what have you tried so far?

Sir, i tried as following way ..

   #!/bin/bash
    filename="/home/vikrant/study/sample.txt"
    exec<${filename}
    value=0
    declare -a arr
    while read line
    do
    varray=(`echo $line | awk '{ split($0, ulist, "|"); for(i=1; i<=11; i++) printf ulist " "; }'`)
    echo "Array Length: " ${#varray[@]}
    done

buts its not working
actually i m very beginner for shell scripting
still i m trying my best

I am not seeing any relationship between the sample data, the desired output, or sample.txt included in the 1st message in this thread and the shell script shown in the 3rd message in this thread.

I was expecting the sample data shown in the 1st message and the data in sample.txt attached to the 1st message to be the same (or at least similar), but they aren't. I don't see any obvious relationship between the desired output and the sample input or sample.txt data.

Please give us an English description of what the format is for the input data. Then explain why the count shown in the first line does not exactly match the number of characters in the following lines, why some groups start with ength-<number>] while others start with Length-<number>] , what determines what should be printed in the 1st two fields of the output, and what determines how much of the text from the input should be copied into the 3rd field in the output.