我有一个包含2列的文件。我想用第二列grep .csv文件。这将产生一个操作。根据第二个生成的输出,我想对第一列进行合并。
例如。
cat file
aa|bb
cc|dd
cat test.csv
aaaaa,bcad,bbee,bbbeeadaf
rerew,afdaf,afdewrew,qerwqe,dd,e,cc
for i in $(cat file| awk -F'|' '{print $2}'); do
echo $i
cat test.csv | egrep -i "$i"
while read line; do
echo "$line"
for j in in $(cat file| awk -F'|' '{print $1}'); do
echo "$j"
grep $j $line
done
done
done
我厌倦了运行此单行代码,但无法正常工作。我认为它没有运行并且卡在我找不到的位置。
for i in $(cat file| awk -F'|' '{print $2}'); do
echo $i
cat test.csv | egrep -i "$i"
while read line; do
echo "$line"
for j in in $(cat file| awk -F'|' '{print $1}'); do
echo "$j"
grep $j $line
done
done
done
for i in $(cat file| awk -F'|' '{print $2}'); do
echo $i
cat test.csv | egrep -i "$i"
while read line; do
echo "$line"
for j in in $(cat file | awk -F'|' '{print $1}'); do
echo "$j"
grep $j
$line
done
done
done
我希望结果的格式为
aa|bb
cc|dd