Loop through file to count field number

后端 未结 3 1892
一向
一向 2021-01-21 23:48

I have a script bash to add users from a .txt file. It is really simple:

name firstname uid gid

space separated values

I want to check

3条回答
  •  遇见更好的自我
    2021-01-22 00:49

    You can use:

    awk 'res = NF!=4{exit} END{exit !res}' file
    

    This will exit with 1 if all rows have 4 columns otherwise it will exist with 0

提交回复
热议问题