开发者

read dat file using unix and validate the data

开发者 https://www.devze.com 2023-03-18 20:11 出处:网络
I have a dat file with some data in it seperated by \'|\' character. I want开发者_如何学Python to read each line and take out 5th and 6th column data( date format) from here and then validate the dat

I have a dat file with some data in it seperated by '|' character.

I want开发者_如何学Python to read each line and take out 5th and 6th column data( date format) from here and then validate the date using unix. I am new to unix . Please let me know how to do it.


Try using an awk script (http://www.manpagez.com/man/1/awk/) for parsing files. Something like

awk -F\| '{print $5, $6}' test.dat

This can then be extended to perform date validation, depending on what validation needs are. For example - http://unix.derkeiler.com/Newsgroups/comp.unix.shell/2003-08/1340.html seems to perform a reasonable amount of validation.

0

精彩评论

暂无评论...
验证码 换一张
取 消