我想要我的输出:
VDD.
GND
AGNDSUB
VMEASPOS.
VMEASNEG
VREFEXT
File1 具有以下信息:
Power and signal
VDD Digital Power This pin provides power supply connection for the digital
blocks.
GND Digital Ground This pin provides ground connection for the digital blocks.
AGNDSUB Ground This pin provides substrate connection.
VMEASPOS Digital Power Voltage to be measured.
VMEASNEG Ground Ground for the voltage to be measured.
VREFEXT Digital Power Reference voltage input of 1.024V %for VSENS calibration.
operating voltage
答案1
和Gnu grep
:
grep -Eow '^[[:upper:]]+' file
答案2
答案3
有几种方法可以解决这个问题。
您可以打印第一个单词,只要它只包含大写字母:
awk '$1 ~ /^[[:upper:]]+$/ {print $1}'
(会打印VDD
,但不会VDD+DDV
)
打印第一个单词,只要它不包含小写字母。
awk 'NF && $1 !~ /[[:lower:]]/ {print $1}'
这将打印 VDD+DDV 或 USA,但不会打印 VDDfoo,但会打印+++
.
您可以在行开头打印字母序列,只要它们都是大写即可:
sed 's/[^[:alpha:]].*//;/^[[:upper:]]\{1,\}$/!d'
或者忽略前导空格:
sed 's/^[[:blank:]]*//;s/[^[:alpha:]].*//;/^[[:upper:]]\{1,\}$/!d'
会匹配VDD
但VDD+xxx
不匹配VDDxxx
答案4
一个perl
办法:
$ perl -Mopen=locale -anle 'print $F[0] if /^[[:upper:]]+\b/' file
VDD
GND
AGNDSUB
VMEASPOS
VMEASNEG
VREFEXT