用于修改文件的Shell脚本

用于修改文件的Shell脚本

本文介绍了用于修改文件的Shell脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据第一个文件寻找shell脚本来修改下面的file2。基本上我需要查找以TAPES开头的行。在file1中,我必须在该行中选择第二列LOC。并在file2中查找匹配的单词,然后在file2中编辑该行,该行中file1的第三列告诉该列应该在file2中编辑,基本上第三列告诉哪个列应该在文件中编辑,file1中的第四列是替换在该列的file2中。我应该通过TAPES到下面的脚本和第二个文件名。我可以获得剧本吗?


./script1 file2 TAPES


file1

TAPES | LOC | 2 | CA

CD | TOP | 5 | CA

TAPES | LOC | 3 | PA

CD | TOP | 5 | CA

TAPES | LOC | 5 | TX


file2

LOC | 2 | STATE | NOT | FILL |

LOC | 2 | PXA | FILL | EMPTY |

LOC | 2 | STATE | NOT | FILL |

解决方案




Looking for shell script to modify file2 below based on first file. Basically I need to look for rows start with "TAPES" in file1, then I have to take 2nd column in that line "LOC" and look for matching word in file2, then edit that line in file2, the third column in file1 in that row tells that column should edit in file2, basically third column tells which column should edit in file, the fourth column in file1 is the replacement in file2 in that column. I should pass "TAPES" to the script and second file name like below. can I get script?.

./script1 file2 TAPES


file1
TAPES|LOC|2|CA
CD|TOP|5|CA
TAPES|LOC|3|PA
CD|TOP|5|CA
TAPES|LOC|5|TX


file2
LOC|2|STATE|NOT|FILL|
LOC|2|PXA|FILL|EMPTY|
LOC|2|STATE|NOT|FILL|

解决方案




这篇关于用于修改文件的Shell脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 07:50