Bash,对列中的数据进行大量数据更改,但仅对特定行进行更改
我有一个数据文件,需要对特定行或列进行批量日期更改。仅适用于以 0003-0 结尾的特定行。还有很多其他类似的,我不需要改变它们。我附上一个例子。在“到期”列下,我需要将日期更改为较新的日期,但仅限于以 -0 结尾的行,我认为我可以对 0003-0 执行此操作,因为它们是相同的。它需要是一个 bash 脚本。我尝试过 awk 和 grep egrep 但收效甚微。
User id: CR 24-FEB-22
Active Orders Report Page 5
141543B NS N 14 14 NO 220224 12468064-0003-1
144461-003B NS N 16 16 NO 220225 12473061-0003-1
143092B NS N 9 9 NO 220225 12472857-0003-1
153674-002G NS N 10 10 NO 220225 12477592-0003-1
150543B NS N 243 243 NO 220228 12477208-0003-1
145874D NS N 96 96 NO 220228 12477238-0003-1
140725D NS N 140 140 NO 220228 12476411-0003-1
------------------------------------------------------------------------------
Material name: 915028-120-60 Thk: 0.375
Part name ST F OrgQty Qty PR Due Order number
-------------------- -- - ------ ------ -- ------ ------------------------------
138540-005H NS N 3 3 NO 220224 12469166-0003-1
134305-005H NS N 17 17 NO 220224 12468143-0003-1
134305-004H NS N 17 17 NO 220224 12468699-0003-1
138540-003H NS N 1 1 NO 220224 12469164-0003-1
134305-004H NS N 17 17 NO 220225 12472767-0003-1
134305-025H NS N 18 18 NO 220225 12473151-0003-1
134305-004H NS N 17 17 NO 220228 12476502-0003-1
134305-005H NS N 17 17 NO 220228 12476974-0003-1
134305-025H NS N 10 10 NO 220228 12475684-0003-1
134305-004H NS N 17 17 NO 220228 12476418-0003-1
------------------------------------------------------------------------------
Material name: 915028-120-48 Thk: 0.375
Part name ST F OrgQty Qty PR Due Order number
-------------------- -- - ------ ------ -- ------ ------------------------------
166764-003B NS N 8 8 NO 220225 12472406-0003-1
166764-003B NS N 8 8 NO 220228 12476160-0003-1
------------------------------------------------------------------------------
Material name: 915028-119-48 Thk: 0.375
Part name ST F OrgQty Qty PR Due Order number
-------------------- -- - ------ ------ -- ------ ------------------------------
134914-001D NS N 46 46 NO 220101 12478187-0003-0
134307-005K NS N 19 19 NO 220101 12470436-0003-0
134838E NS N 150 150 NO 220101 12474868-0003-0
134307-005K NS N 19 19 NO 220101 12474436-0003-0
146376C NS N 24 24 NO 220203 12468515-0003-1
I have a data file that I need to do a mass date change on specific lines or column. It is only on specific lines that end in 0003-0. There are many others similar and I do not need them changed. I am attaching an example. Under column Due I need to change the date to a newer date but only on lines that have the ending with -0 I think I can do it for 0003-0 as they are the same. It needs to be a bash script. I have tried awk and grep egrep with little success.
User id: CR 24-FEB-22
Active Orders Report Page 5
141543B NS N 14 14 NO 220224 12468064-0003-1
144461-003B NS N 16 16 NO 220225 12473061-0003-1
143092B NS N 9 9 NO 220225 12472857-0003-1
153674-002G NS N 10 10 NO 220225 12477592-0003-1
150543B NS N 243 243 NO 220228 12477208-0003-1
145874D NS N 96 96 NO 220228 12477238-0003-1
140725D NS N 140 140 NO 220228 12476411-0003-1
------------------------------------------------------------------------------
Material name: 915028-120-60 Thk: 0.375
Part name ST F OrgQty Qty PR Due Order number
-------------------- -- - ------ ------ -- ------ ------------------------------
138540-005H NS N 3 3 NO 220224 12469166-0003-1
134305-005H NS N 17 17 NO 220224 12468143-0003-1
134305-004H NS N 17 17 NO 220224 12468699-0003-1
138540-003H NS N 1 1 NO 220224 12469164-0003-1
134305-004H NS N 17 17 NO 220225 12472767-0003-1
134305-025H NS N 18 18 NO 220225 12473151-0003-1
134305-004H NS N 17 17 NO 220228 12476502-0003-1
134305-005H NS N 17 17 NO 220228 12476974-0003-1
134305-025H NS N 10 10 NO 220228 12475684-0003-1
134305-004H NS N 17 17 NO 220228 12476418-0003-1
------------------------------------------------------------------------------
Material name: 915028-120-48 Thk: 0.375
Part name ST F OrgQty Qty PR Due Order number
-------------------- -- - ------ ------ -- ------ ------------------------------
166764-003B NS N 8 8 NO 220225 12472406-0003-1
166764-003B NS N 8 8 NO 220228 12476160-0003-1
------------------------------------------------------------------------------
Material name: 915028-119-48 Thk: 0.375
Part name ST F OrgQty Qty PR Due Order number
-------------------- -- - ------ ------ -- ------ ------------------------------
134914-001D NS N 46 46 NO 220101 12478187-0003-0
134307-005K NS N 19 19 NO 220101 12470436-0003-0
134838E NS N 150 150 NO 220101 12474868-0003-0
134307-005K NS N 19 19 NO 220101 12474436-0003-0
146376C NS N 24 24 NO 220203 12468515-0003-1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
似乎我在询问错误的输入,因为这是需要更改日期并由另一个程序运行的输出。我需要做的是在 .csv 文件中找到末尾有相应 -0 的日期,并将日期更改为今天的日期。我本来打算使用 grep -o 来找到它,但我可能只是使用 awk 来查找第六列并将这些列的日期更改为今天的日期。
Seems I am asking about the wrong input as this is the output that needs to have the date changed and is run by another program. What I need to do is find in a .csv file the date that has a corresponding -0 on the end and change dates for those to say todays date. I was going to
grep -o
to find this but I may just use awk to find the 6th column and change the date for those columns to todays date.