normally I would use Python/Perl for this procedure but I find myself (for political reasons) having to pull this off using a bash shell.
I have a large tab delimited file that contains six columns and the second column is integers. I need to shell script a solution that would verify that the file indeed is six columns and that the second column is indeed integers. I am assuming that I would need to use sed/awk here somewhere. Problem is that I’m not that familiar with sed/awk. Any advice would be appreciated.
Many thanks!
Lilly
Well you can directly tell
awkwhat the field delimiter is (the -F option). Inside yourawkscript you can tell how many fields are present in each record with the NF variable.Oh, and you can check the second field with a regex. The whole thing might look something like this:
That’s probably close but I need to check the regex because Linux regex syntax variation is so insane. (edited because grrrr)