How to assign each line in a text to an array in shell scripting? -


i have text file named "raj.txt" containing following content:


raj magesh popey ravi


how can assign each word array element? a[0]=raj a[1]=magesh a[2]=popey a[3]=ravi

try bash:

while ifs= read -r line    set -- $line    echo "$1"    echo "$2" done < file 

Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -