【发布时间】:2018-01-02 19:09:19
【问题描述】:
首先,如果我在发布之前没有遇到类似的答案,我深表歉意。
我正在尝试根据几个条件创建第三个文件。
我有两个输入文件
file1(制表符分隔):-
X_ID1 y_id11 num1
X_ID2 y_id31 num2
X_ID3 y_id34 num3
X_ID4 y_id23 num4
X_ID5 y_id2 num5
...
...
文件 2:-
BIOTIC AND ABIOTIC STRESS
x_id2
REGULATION OF TRANSCRIPTION
x_id1
x_id4
HORMONES
x_id5
REGULATION
x_id6
x_id13
...
...
****请注意,文件 1 的第 1 列是大写的,文件 2 中的数据是小写的
我想要的是有一个输出文件(file3)如下:-
BIOTIC AND ABIOTIC STRESS
y_id31
REGULATION OF TRANSCRIPTION
y_id11
y_id23
HORMONES
y_id2
...
...
基本上,如果我想到一个“伪代码”,它会如下所示:-
while read $line from file2; do
if [[line1 != x_*]]; then
print $line
else
match $line (case insensitively) with column 1 of file1 and print respective column2 of file1
fi
done
您能帮我解决这个问题吗?
提前非常感谢!
【问题讨论】:
标签: bash if-statement awk sed while-loop