Unable to separate semi-colon separated line awk

前端 未结 3 2102
傲寒
傲寒 2020-12-20 21:30

I am trying to do the following:

  1. Read a file line by line.
  2. Each line has the following structure: field1;field2;field3
  3. Use
3条回答
  •  粉色の甜心
    2020-12-20 21:43

    Your awk has no idea what --field-separator=";" means so when you do this:

    awk --field-separator=";" '{print $1}'
    

    your awk is still using the default FS of a space, and so $1 contains your whole input line while $2 and $3 are empty. Use -F';' to set the FS.

    You are WAY, WAY off the mark in how to write the script you want. If you tell us more about what "process each field" is, we can help you.

提交回复
热议问题