我使用类似于以下示例的制表符分隔文件:
java/awt/Graphics2D/results.json -0.0007254401050271753
java/util/Collection/results.json 0.03368847875680803
java/util/Map$Entry/results.json 0.0
java/util/Calendar/results.json 0.043459993814160214
java/io/ObjectInputStream/results.json 0.004388257233926218
java/util/Set/results.json 0.027563163785955025
java/lang/NoClassDefFoundError/results.json 0.0
java/io/ByteArrayOutputStream/results.json 0.005683957785502014
javax/xml/parsers/DocumentBuilderFactory/results.json 0.0
java/util/HashSet/results.json 0.00041155025194439254
java/lang/reflect/Field/results.json 0.00890593203598622
java/io/BufferedInputStream/results.json -0.002988394526148186
我想打印零值的行,但我无法让它工作。这是我尝试过的:
awk '$2 == 0.0 { print $1 $2; }'
awk '$2 ~ /^0.0$/ { print $1 $2; }'
awk '! $2 { print $1 $2; }'
但他们都没有返回任何东西。当我用 替换相等时<=
,我得到了结果。'0.0' 的内部表示是否与零不同,或者我在这里遗漏了什么?
[编辑]
正如第一条评论和答案所指出的那样,我的方法确实适用于给定的示例。由于我仍然无法为我的文件获得所需的结果,我现在提供完整的文件:
type difference
java/util/zip/ZipEntry/results.json 0.02811540961236958
java/io/File/results.json 0.04152288811788907
javax/xml/parsers/SAXParser/results.json 0.0
java/lang/reflect/Constructor/results.json 0.0009129948091427531
java/io/Reader/results.json -0.00043988180335940985
org/w3c/dom/NodeList/results.json 0.006532216750947728
java/io/FileOutputStream/results.json 0.007256000537915197
java/lang/StringBuffer/results.json 0.007679996705180603
java/util/Timer/results.json 0.016366219196432108
java/util/Stack/results.json 0.006318970191216411
java/util/HashMap/results.json 0.007887416771271583
java/util/regex/Pattern/results.json 0.0
java/lang/SecurityManager/results.json 0.022447250291888987
java/lang/Integer/results.json 0.0009540861574682813
java/lang/reflect/Method/results.json 0.0034659896518139943
java/awt/Graphics2D/results.json -0.0007254401050271753
java/util/Collection/results.json 0.03368847875680803
java/util/Map$Entry/results.json 0.0
java/util/Calendar/results.json 0.043459993814160214
java/io/ObjectInputStream/results.json 0.004388257233926218
java/util/Set/results.json 0.027563163785955025
java/lang/NoClassDefFoundError/results.json 0.0
java/io/ByteArrayOutputStream/results.json 0.005683957785502014
javax/xml/parsers/DocumentBuilderFactory/results.json 0.0
java/util/HashSet/results.json 0.00041155025194439254
java/lang/reflect/Field/results.json 0.00890593203598622
java/io/BufferedInputStream/results.json -0.002988394526148186
java/util/Random/results.json 0.011227287619054893
java/util/TimeZone/results.json 0.024665400046989694
java/lang/Class/results.json 0.07421947121451256
java/util/concurrent/atomic/AtomicReference/results.json 0.10331150665256295
java/io/Writer/results.json -0.009594193559632203
java/text/MessageFormat/results.json 0.0
java/util/concurrent/locks/Lock/results.json 0.0
java/lang/Process/results.json 0.03305842089211253
java/awt/Graphics/results.json -0.014799823847054583
java/io/ObjectInput/results.json 0.0043643251190484955
java/io/DataOutputStream/results.json 0.028180125582963456
java/net/ServerSocket/results.json 0.0
java/lang/CharSequence/results.json 0.0014546156264344523
org/w3c/dom/Document/results.json 0.044205828635986544
java/lang/ref/SoftReference/results.json 0.0
java/util/Date/results.json 0.03739704095408358
java/util/BitSet/results.json 0.01595348836239574
java/beans/PropertyChangeEvent/results.json 0.0736002108400371
java/lang/Throwable/results.json 0.015442674292838077
org/xml/sax/InputSource/results.json 0.00504041008343914
java/util/concurrent/atomic/AtomicBoolean/results.json 0.0
java/util/Enumeration/results.json 0.0
java/io/OutputStream/results.json 0.03207385133784557
javax/swing/JMenuItem/results.json 0.007580588697566837
java/util/LinkedHashSet/results.json -0.016756794274537468
java/util/ListIterator/results.json -0.020853784272820364
java/util/PropertyResourceBundle/results.json 0.0
java/util/TreeSet/results.json 0.044817278597274135
java/io/DataInputStream/results.json 0.053026460924931906
java/sql/PreparedStatement/results.json 0.09681700283436634
java/sql/Connection/results.json 0.13935867828592935
org/xml/sax/helpers/AttributesImpl/results.json 0.0
java/lang/Iterable/results.json 0.0
java/util/Hashtable/results.json 0.002679420570760871
org/w3c/dom/Text/results.json 0.0
java/util/Properties/results.json 0.11327875446939961
java/util/concurrent/atomic/AtomicLong/results.json -0.010251951289681704
org/xml/sax/SAXParseException/results.json 0.07333548447668281
java/lang/Boolean/results.json 0.0047512888249205965
java/net/URL/results.json 0.10408154020680904
java/io/PrintWriter/results.json 0.03420358878056462
java/util/ResourceBundle/results.json 0.0
java/lang/Enum/results.json 0.032303227721100725
java/util/SortedMap/results.json 0.08744496853140682
java/nio/ByteBuffer/results.json 0.10982055662447976
javax/swing/JInternalFrame/results.json 0.0
javax/swing/JPanel/results.json 0.029944242845839852
java/lang/Double/results.json 0.012100663817329216
java/sql/ResultSet/results.json 0.0466592420153662
java/util/LinkedList/results.json 0.024632903602906486
org/w3c/dom/Node/results.json 0.10037281423252875
org/w3c/dom/NamedNodeMap/results.json 0.0
java/util/regex/Matcher/results.json 0.026061882971817107
java/lang/Runnable/results.json 0.0
javax/xml/parsers/SAXParserFactory/results.json 0.0
java/io/InputStream/results.json 0.016656317939729548
java/util/Map/results.json 0.037111411767002944
java/io/BufferedReader/results.json 0.04313808075138814
java/util/LinkedHashMap/results.json 0.12558632507110923
java/util/Iterator/results.json 0.001078276973821346
java/io/StringWriter/results.json -0.01217951196013567
java/lang/String/results.json 0.10887317528796281
org/xml/sax/XMLReader/results.json 0.0019673750860798034
java/lang/Exception/results.json 0.02072166912805773
java/lang/StringBuilder/results.json -0.008138028734336222
java/lang/ClassLoader/results.json 0.13500196641014406
java/util/StringTokenizer/results.json 0.0
org/xml/sax/Attributes/results.json 0.037444901309106715
java/util/Locale/results.json -0.002155567254523705
org/w3c/dom/ProcessingInstruction/results.json 0.0
java/awt/Container/results.json 0.17531504176646578
org/w3c/dom/Comment/results.json 0.18453512321427057
java/net/Socket/results.json 0.0015579907762824918
java/lang/Thread/results.json 0.13990245294661952
java/awt/Component/results.json 0.006227573200654146
java/util/List/results.json 0.03846009954116536
java/lang/Object/results.json 0.1044811092147323
java/util/Dictionary/results.json 0.008123421708587264
java/lang/Long/results.json -0.03193234419266067
javax/swing/text/JTextComponent/results.json 0.021581000121873306
javax/xml/transform/Transformer/results.json 0.0
javax/swing/JButton/results.json -0.012595220962732578
java/util/ArrayList/results.json 0.018424764828314788
javax/xml/namespace/QName/results.json 0.0
org/w3c/dom/Element/results.json 0.08394591221121561
java/io/FilterInputStream/results.json 0.31143660022857694
java/awt/geom/Point2D/results.json -0.01419500947802077
javax/xml/parsers/DocumentBuilder/results.json 0.08379309434821058
java/util/Vector/results.json 0.03531433307692444
java/awt/geom/AffineTransform/results.json 0.02444537705524863
java/io/RandomAccessFile/results.json 0.013654524542530022
java/io/PrintStream/results.json -0.0054164506429096315
java/net/URI/results.json 0.1156988886086383
java/util/TreeMap/results.json -0.009435345113169347
java/math/BigInteger/results.json 0.13314587395291244
java/lang/ThreadLocal/results.json 0.0018628454065079403
java/lang/ref/ReferenceQueue/results.json 0.0
java/io/ObjectOutputStream/results.json 0.0017384824717933123
我意识到我在这里有一个标题 - 这会造成麻烦吗?但是,当我用 grep 删除标题时,它仍然不起作用。