小编Kis*_*ses的帖子

用于填充文件中日期之间空白的 Unix 命令

我想查找具有相同姓名和年龄但不同日期的记录。然后,如果上一个日期和下一行日期之间有差距,我必须填补这个差距。

样本数据文件.txt

20230907,Allan,29,Marketing
20230912,Allan,29,VirtualAssistant
20230913,Allan,29,Programmer
20230920,Daniel,28,Engineer
20230922,Daniel,28, Photographer
Run Code Online (Sandbox Code Playgroud)

到目前为止我做了什么:

#create zero byte file for all filled gaps
cat /dev/null > fillGap.txt
For line in `awk -F"," '{print $2","$3}' file.txt`;do
#if name,age NOT found in fillGap.txt then grep everything that matches in file.txt
if [[ -z `grep -w ${line} fillGap.txt` ]];then
grep -w ${line} file.txt > MatchNameAge.txt
#this is the part of checking if there is a gap between dates and if so, gaps will be filled. I haven't figured it …
Run Code Online (Sandbox Code Playgroud)

unix awk

4
推荐指数
1
解决办法
137
查看次数

标签 统计

awk ×1

unix ×1