Agnus Dei (jackal) wrote,
Agnus Dei
jackal

You have two fields in a file and you want to call both of them as variables in bash.

You have two fields in a file and you want to call both of them as variables in bash.  Here's how to access them:

$ cat test.txt
aaaaa:apple
bbbbb:bee
ccccc:cat
ddddd:dog
eeeee:eagle

$ cat test.txt | while IFS=":" read a b; do echo "A=$a  B=$b" ; done
A=aaaaa  B=apple
A=bbbbb  B=bee
A=ccccc  B=cat
A=ddddd  B=dog
A=eeeee  B=eagle


Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

  • 0 comments