基于if语句的awk条件列选择

时间:2019-03-14 17:28:19

标签: linux awk

我正在尝试首先根据条件列选择以及<ItemGroup> <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="2.2.0" /> </ItemGroup> 条件获得行。

我有以下要尝试捕获的数据。

>=

这是我试图获得完全匹配的内容:

[root@elastic_dev ~]# curl -s -XGET http://127.0.0.1:9200/_cat/indices?v
health status index                           uuid                   pri rep docs.count docs.deleted store.size pri.store.size
green  open   fx-syslog-2019.02.12            jbv1mtuET3e8ps2jrJfpjQ   5   1   25964532            0     19.2gb          9.6gb
green  open   fx-syslog-2019.02.20            _XwyMsX2RWmPkeh8osWrwQ   5   1   16760019            0      3.9gb          1.9gb
green  open   dfx-syslog-2019.02.13           EfNnTK1lQNm5-SG3DCSqQw   5   1   13378826            0     15.8gb          7.9gb
green  open   fx-rmlog-2019.02.08             OmA4RlipTLKtd6L73aBUZg   5   1     149320            0     92.3mb         46.2mb
green  open   dfx-syslog-2019.02.26           Z67qG7XsQJ6AldMSKh9FYw   5   1    2373058            0    709.8mb        355.5mb
green  open   fx-syslog-2019.02.23            WHDwz10jTWibFfKaAdPT0A   5   1   24857467            0     10.6gb          5.3gb
green  open   dfx-syslog-2019.03.10           07sub6BdS9GJvXX-K_XOpQ   5   1     901571            0    356.3mb        178.3mb
green  open   dfx-rmlog-2019.03.02            -C6nxcw5Q7C_4208wqKrXA   5   1         77            0    881.6kb        390.2kb
green  open   dfx-rmlog-2019.02.14            m49jDHKERuuw1WxBC6nQHg   5   1        423            0      1.8mb        923.6kb
green  open   fx-rmlog-2019.02.25             Lnc2c9XxT4i6OEQYrgJPYw   5   1     267017            0    132.9mb         66.5mb
green  open   fx-rmlog-2019.03.02             M98OSpODSFaLpzZUkDzRdw   5   1     205473            0    120.9mb         60.2mb
green  open   fx-rmlog-2019.03.12             pN5cTuEeSbeUKZuqXUheYA   5   1     138606            0     92.7mb         46.2mb
green  open   fx-rmlog-2019.03.04             Tk_ssK2nQemCdSFoPNjRYg   5   1      42865            0     34.1mb           17mb
green  open   fx-rmlog-2019.03.10             m_D8KlgGTCK9UzqOXCqmXQ   5   1      81820            0     54.5mb         27.5mb
green  open   fx-syslog-2019.02.24            xY_go0z1SN2TD7POQB49sw   5   1   22749651            0      8.8gb          4.4gb
green  open   dfx-syslog-2019.12.21           gq9XqNGtSzG1jMS5SfxMeQ   5   1          1            0     19.6kb          9.8kb
green  open   fx-syslog-2019.03.09            X68d8uxiR6SMnMp64-1Rsw   5   1   10807403            0      5.8gb          2.9gb
green  open   dfx-rmlog-2019.03.06            j5NU-oCqTkacCfQ4Ar2yOQ   5   1        149            0    901.7kb        443.7kb
green  open   dfx-syslog-2019.03.02           b3jKzXKFSuGL82zabwzZ2Q   5   1     899680            0    356.3mb        178.3mb
green  open   dfx-rmlog-2019.02.20            fiMCLhKpRyyU7H-mUHwpag   5   1        154            0      1.1mb        635.5kb
green  open   fx-rmlog-2019.02.09             T-Jc96ClTb-u9cfpG2g42w   5   1      30849            0     32.3mb         16.3mb
green  open   fx-syslog-2019.02.26            L9n5dxQcTfyitQ4H9k8ZdQ   5   1   30523931            0      8.9gb          4.4gb
green  open   dfx-rmlog-2019.02.07            M9B8ZU_rRWa-V1lxGmSoZg   5   1       1471            0      3.6mb          1.8mb
green  open   fx-syslog-2019.03.11            iD9j2LRqTK6To6rASqNdiA   5   1   11966907            0      4.5gb          2.2gb
green  open   dfx-rmlog-2019.02.15            dLYc-g8bQNWFCoqOdYeYKg   5   1        144            0      1.1mb        591.7kb
green  open   dfx-syslog-2019.02.19           M7YT324bR9CHZ-MnTR9k_g   5   1    1991688            0    639.2mb        320.2mb
green  open   fx-rmlog-2019.02.26             dKILAkXUTl2B_Joq2FB38g   5   1     274984            0    153.8mb         77.2mb
green  open   dfx-syslog-2019.03.04           phWMsZ2LQlKyI21ODOJATA   5   1     919713            0    365.3mb          183mb
green  open   fx-syslog-2019.03.10            TLA7eIowQHuyGywGRKSKhg   5   1    9400503            0      4.7gb          2.3gb
green  open   dfx-rmlog-2019.02.10            IWf8PodLSkWDmhuIQQbXxw   5   1        280            0      1.4mb        709.8kb
green  open   dfx-rmlog-2019.02.13            wNHZITrSTUOQ42NTRofJ4A   5   1         80            0        1mb        480.9kb
green  open   dfx-rmlog-2019.02.28            M9NJ71f4RDmqn7nfvrugmQ   5   1         57            0    772.5kb        386.2kb
green  open   fx-rmlog-2019.02.13             er_URrLLTISILYuoNt8YYg   5   1     307451            0    180.5mb         90.6mb
green  open   .monitoring-kibana-6-2019.03.11 plWsIAUwSx-xcheapgehgA   1   1      17272            0      6.3mb          3.2mb
green  open   .monitoring-es-6-2019.03.09     QZNIkOjqTeCwjMv30hNXhg   1   1    1283192        13000      1.8gb        930.3mb
green  open   fx-syslog-2019.02.18            URhBAzUhRm-nw2Pr89wXKA   5   1   19620547            0      3.8gb          1.9gb
green  open   fx-rmlog-2019.02.11             HIYGmNJjTZSgTKNkCeyuOQ   5   1     160720            0     96.8mb         48.8mb
green  open   fx-rmlog-2019.02.21             FhJ4fDTfRVu1cwl_R3JU4Q   5   1     348209            0    180.5mb         90.7mb
green  open   dfx-syslog-2019.02.22           JFw8vklWT0-XT9jY_y-Fhw   5   1    2605701            0    789.3mb        393.3mb
green  open   fx-syslog-2019.02.16            j1WLsq8pSDWh2M9N7kC4vQ   5   1     525034            0    218.7mb        109.3mb
green  open   .monitoring-kibana-6-2019.03.13 iCuQmOlIT7q627CrgEMhRw   1   1      17272            0      6.3mb          3.2mb
green  open   dfx-syslog-2019.02.20           Ff9F67syTciZQJeItKcvwg   5   1    2192436            0    696.4mb          349mb
green  open   fx-rmlog-2019.02.28             buiwc8dpSv63Z3235M9FOg   5   1     296064            0    176.2mb         88.8mb
green  open   fx-rmlog-2019.02.14             qasehsLqSpawvB-sznhvFA   5   1     357532            0    214.8mb        107.7mb
green  open   dfx-syslog-2019.01.28           c_QNJpycQDGms4GfGo15ZQ   5   1        845            0    845.2kb        422.6kb
green  open   fx-syslog-2019.03.04            sksLBFetT12KFvRhjJizbg   5   1    8541213            0      3.5gb          1.7gb
green  open   fx-syslog-2019.03.08            wCqHmQBYRKG6uKbWmzLJNg   5   1   13116025            0      5.5gb          2.7gb
green  open   dfx-rmlog-2019.02.12            crLX5ZCvQJKDojiNozqRxQ   5   1         49            0      746kb        366.2kb
green  open   dfx-rmlog-2019.03.04            gtpL0ltrTgqgrUfj9F4IFg   5   1       2111            0      1.7mb        952.9kb
green  open   fx-rmlog-2019.02.12             7VsFL5b9TFGjsiCHsQa_2Q   5   1     934269            0    406.8mb        204.3mb
green  open   dfx-syslog-2019.02.23           MWCatRh1TxCPJPy6xnlISQ   5   1    1956621            0    622.8mb        312.6mb
green  open   dfx-syslog-2019.02.28           GaexVxLISHai8HHz3f8QXQ   5   1     956417            0    378.5mb        189.5mb
green  open   dfx-syslog-2019.12.19           lb7Le8VESz2sygAldk95RA   5   1       8797            0      7.4mb          3.7mb
green  open   fx-rmlog-2019.03.08             ps4zHjtxQ3GIiZp-jBY6KQ   5   1     509687            0    291.9mb        146.1mb
green  open   dfx-syslog-2019.02.12           ZkZKzeUsQJKod_2JDiIOGw   5   1   13203227            0     15.6gb          7.8gb
green  open   dfx-rmlog-2019.03.09            xdLhItGuQvqTz5-6ylJkPA   5   1       1605            0      1.5mb          701kb
green  open   fx-rmlog-2019.02.20             oJvjIuKhRJqhIgmeK-RWyw   5   1     220840            0      141mb         69.9mb
green  open   dfx-syslog-2019.02.10           -qL7Cz2tTAKNBm8gtS8MZw   5   1   13000846            0     15.2gb          7.6gb
green  open   dfx-rmlog-2019.02.19            nxNwBBeETxOPFpTHsvWNQQ   5   1        142            0    954.6kb        466.8kb
green  open   dfx-syslog-2019.03.15           jiWDYi1DQGKUQcztO05Qeg   5   1          6            0    110.5kb         55.2kb
green  open   dfx-rmlog-2019.03.13            J9SI0gVYR02IP3PurReicA   5   1       8085            0      3.6mb          1.8mb
green  open   .kibana_1                       VKqbSbHCSS-8aZef7Gwojw   1   1         12            5    152.9kb         76.4kb
green  open   dfx-rmlog-2019.02.09            RRSfWWOqTumwjUfqFedmrQ   5   1        319            0      1.4mb        718.5kb
green  open   dfx-rmlog-2019.02.26            8p-zSsHOStWsyj-y9_t2mA   5   1         59            0    897.1kb        441.8kb
green  open   dfx-syslog-2019.12.20           VKArbr4hTli3geXxK4JZEg   5   1       6514            0      5.2mb          2.6mb
green  open   .monitoring-kibana-6-2019.03.09 8Guprh_NRuyNBLsqjCXVIw   1   1      17272            0      6.3mb          3.1mb
green  open   fx-rmlog-2019.03.05             Q6Mnaz6zQA-EA3Xv_QOrxw   5   1     130319            0     83.6mb           42mb
green  open   fx-rmlog-2019.03.01             V1yJmikvSTiKkpI_QGRdrQ   5   1      65601            0     52.8mb         26.4mb
green  open   dfx-syslog-2019.03.06           kuqk6ENkRlK-lyKPqqZnOw   5   1     991613            0      388mb        194.2mb
green  open   dfx-syslog-2019.02.25           Qwlyf0srTyqh1G_KhpBSyA   5   1    2194614            0    688.3mb        343.1mb
green  open   fx-syslog-2019.02.17            3bifRPeaT6izVwBiE_6TbA   5   1   13235363            0      2.8gb          1.4gb
green  open   .monitoring-es-6-2019.03.11     RUk8OJx_QUuSejxry89xfg   1   1    1336375        16320      1.8gb        968.8mb
green  open   fx-rmlog-2019.02.27             QWgZV8wDT6GwwKINgg9PkQ   5   1     256652            0    165.8mb         83.4mb
green  open   dfx-syslog-2019.02.24           Sf2dY7GRQhi5O0Jvt5TQPQ   5   1    1920288            0    612.4mb        307.6mb
green  open   fx-syslog-2019.03.06            k6E-u3OWQcGaWGRMLw9svg   5   1    9085606            0      3.7gb          1.8gb
green  open   dfx-syslog-2019.03.14           P1zZJ7mASiedEhY0TFZwwg   5   1     736565            0    302.4mb        153.7mb
green  open   fx-rmlog-2019.02.23             qwWHg-00RR6BB9KTACdR5A   5   1     202521            0      122mb         61.1mb
green  open   fx-rmlog-2019.03.07             EKF8oOVNTX2UPwifxy5KGw   5   1     618244            0    319.6mb          161mb
green  open   fx-rmlog-2019.03.14             QdYRWWlsR0-TC_o6mwi4-Q   5   1     166950            0    119.7mb         60.4mb
green  open   fx-syslog-2019.03.05            lBoLmSy_S7m7I5uSs8Hftw   5   1    8999403            0      3.6gb          1.8gb
green  open   fx-rmlog-2019.02.10             blvHAID0SEuWuMKxzVlsVg   5   1     182428            0    149.6mb         74.8mb
green  open   dfx-rmlog-2019.02.23            u3C_XlZ-T2mH_H6Me3iH0w   5   1         88            0    743.8kb        378.6kb
green  open   dfx-syslog-2019.03.11           vdT0bu65SA6VsKB-WzFiSg   5   1     929361            0    367.9mb        183.9mb
green  open   fx-rmlog-2019.03.06             HqGSTKAXR1aLE9Wdau7QFQ   5   1     393986            0    186.6mb         93.9mb
green  open   fx-rmlog-2019.02.17             ZDsUkHyWQq6SeN63kPWQlg   5   1     165954            0    130.5mb           66mb
green  open   fx-syslog-2019.03.03            0yWYZP0QQ_ODaXJzZDslOA   5   1   10238221            0      4.8gb          2.4gb
green  open   fx-rmlog-2019.03.11             vTri1lYvRHW0bmj-UoO0dg   5   1      64628            0     60.3mb           30mb
green  open   fx-syslog-2019.02.21            AlKpQiVaSsSy7lQuaVFtag   5   1   30359920            0      8.6gb          4.3gb
green  open   .monitoring-es-6-2019.03.12     RYytKVoRSpKm0O4Ucxm9Hw   1   1    1369906        12548      1.9gb       1002.9mb
green  open   dfx-rmlog-2019.03.14            GKa9wHHRSOWt-K3tlD0GVg   5   1         67            0    779.8kb        389.9kb
green  open   .monitoring-kibana-6-2019.03.14 T-uqE4T5QRONBiYpQFyQlw   1   1      12318            0      4.7mb          2.3mb
green  open   fx-rmlog-2019.02.15             Nbd_iOvqRRONuTbTpiS47g   5   1     339596            0    221.3mb        110.2mb
green  open   fx-rmlog-2019.03.03             Tbh_3EcNQx296tBIB3V_Xg   5   1      50119            0       32mb         16.1mb
green  open   dfx-syslog-2019.03.05           dqIn_5oYQxqPFxfSAcHEeg   5   1     935284            0    367.7mb        184.4mb
green  open   fx-rmlog-2019.02.18             jYtEs4DZQCWCPZ6LWhVntg   5   1    1155128            0    366.2mb        183.2mb
green  open   dfx-rmlog-2019.02.27            p-wztyhCREy8jKpxZUq9Bw   5   1       2145            0      5.1mb          2.5mb
green  open   fx-syslog-2019.02.14            wNMa0id5SkuxnkFdmiG-PA   5   1   19583849            0     14.2gb          7.1gb
green  open   dfx-syslog-2019.02.16           PoFhIj5OTYSsZPxyN4rgsw   5   1   12343056            0     13.4gb          6.7gb
green  open   fx-rmlog-2019.03.13             GZFXCs6rSpqSp7CAqDEMdQ   5   1     192636            0    116.5mb         58.3mb
green  open   .monitoring-es-6-2019.03.08     -rwiXFmPTqSHCeeks77aGQ   1   1    1248310        10045      1.7gb        892.3mb
green  open   fx-syslog-2019.03.12            WQlpswdrSYuzrcRLPNoRIw   5   1   14142879            0      5.2gb          2.6gb
green  open   .monitoring-kibana-6-2019.03.12 4C0ZUDUKRyucNTfD2v4igw   1   1      17272            0      6.5mb          3.2mb
green  open   fx-rmlog-2019.02.19             w4DBV_01QIyXyMgEE-pMsg   5   1     631471            0    241.4mb        121.4mb
green  open   dfx-syslog-2019.02.11           wivt1yfhT5qhjbgF1Iog_Q   5   1   13223543            0     15.6gb          7.8gb
green  open   dfx-syslog-2019.12.09           hF9Eb8vOShOEXxpypEED-Q   5   1      15253            0     12.2mb            6mb
green  open   dfx-syslog-2019.03.03           KhkLv8xyR32jXjGgFx6chw   5   1     929180            0      369mb        184.7mb
green  open   dfx-rmlog-2019.02.22            KTxjOWSfSumS1oaPZjsKQQ   5   1        144            0    815.2kb        425.2kb
green  open   fx-syslog-2019.02.25            heLbuyxvSrWp7MeNotaw6w   5   1   28042532            0      8.4gb          4.2gb
green  open   dfx-rmlog-2019.02.11            7CxbKbD3Sdu5iPDpyeJbfw   5   1        159            0      1.3mb        619.4kb
green  open   fx-rmlog-2019.02.16             jEWwgOE9TNuvuormAVuanQ   5   1     216532            0      163mb         81.2mb
green  open   fx-syslog-2019.02.27            0jkBV0_nTA67f8J79kOhHw   5   1   19647318            0      6.1gb          3.1gb
green  open   .monitoring-es-6-2019.03.10     yRlco9_ARDSrZqQNu2y2wg   1   1    1322193        10580      1.8gb        970.4mb
green  open   dfx-rmlog-2019.03.05            x78splB2RkSCVMa2oGPlJA   5   1         55            0    947.2kb          467kb
green  open   .monitoring-es-6-2019.03.14     -KvEagOoSA61wDj5peiQXw   1   1    1031560        19210      1.4gb        750.8mb
green  open   fx-syslog-2019.02.22            23Cqlr7nQb-vJYNPbfhCVA   5   1   29486926            0      9.2gb          4.6gb
green  open   fx-syslog-2019.02.19            Uw8GmCYVTz-Yxv9JggSm7g   5   1   16468229            0      3.1gb          1.5gb
green  open   dfx-syslog-2019.03.08           B4mzTznDTQaB6-2KU6qXPg   5   1     931720            0    368.7mb        184.8mb
green  open   dfx-rmlog-2019.02.21            kDGZa3hkSFKe8YhgpxDcWQ   5   1        109            0      1.2mb        675.5kb
green  open   dfx-syslog-2019.02.21           f992UlCjSS6nuK9f4O61Vg   5   1    2337145            0    730.8mb        366.5mb
green  open   dfx-rmlog-2019.03.10            s5ew9ejzSECCfxvDpHhHRA   5   1       1376            0      1.4mb        754.6kb
green  open   dfx-syslog-2019.02.17           pgLK1xxjR9OrqUbstae0zw   5   1    2658096            0        1gb          542mb
green  open   fx-syslog-2019.03.14            3Bquy2c2TjOYum_V49JDnA   5   1   33130761            0      9.1gb          4.8gb
green  open   dfx-syslog-2019.03.01           FnFh6_7VQDi45bBGEm_Qcw   5   1     959313            0    380.4mb        190.4mb
green  open   dfx-syslog-2019.02.27           3nF-huf0T7WW49Acq5jdsg   5   1   13777000            0      5.1gb          2.5gb
green  open   dfx-rmlog-2019.02.16            g_-KmpOtSkqjJO9svMmblg   5   1        595            0      2.2mb          1.1mb
green  open   fx-syslog-2019.03.02            Ao7aj6BqQlugjWUt8z9mwA   5   1   12703213            0      6.2gb          3.1gb
green  open   .monitoring-es-6-2019.03.13     WhHufs3mSr-HgxE8_f_3SQ   1   1    1403238         8640      1.9gb            1gb
green  open   dfx-syslog-2019.02.18           DOZgIZ1rSCeIzNDcbCHkjw   5   1    4987072            0        2gb            1gb
green  open   fx-rmlog-2019.03.09             _G2Fv5zWTfa8YrNlW75Gww   5   1     152300            0     95.7mb         48.1mb
green  open   fx-syslog-2019.03.07            v-z2k7njQpKrb9ADTWMApQ   5   1   11245179            0      4.3gb          2.1gb
green  open   dfx-rmlog-2019.03.01            bhdPdZGJSE6RhMIfrx_gFg   5   1         64            0   1011.7kb        511.4kb
green  open   dfx-syslog-2019.03.07           3u3IzsDTTCSKII32-4Fa4A   5   1    1002120            0    394.8mb        197.3mb
green  open   dfx-rmlog-2019.02.25            HUfkeF5yS5-YlMTmS4IiLQ   5   1         64            0        1mb        521.8kb
green  open   fx-rmlog-2019.02.22             -67QLnDfQBi5lnNUx6CRgA   5   1     187189            0    113.2mb         56.5mb
green  open   dfx-rmlog-2019.02.18            tqLbBzUyTzenFAy_T0GarA   5   1       2950            0      5.7mb          2.9mb
green  open   dfx-syslog-2019.03.12           -zJX4E11SKe8gsuvUsCGXQ   5   1    1058258            0    412.1mb        206.3mb
green  open   dfx-syslog-2019.02.15           azQye17nSpKDnVSSHjVAuw   5   1   13360599            0     15.8gb          7.9gb
green  open   fx-syslog-2019.02.15            jpnMUdXPQY27cF853vu2Mw   5   1     419873            0    351.4mb        175.5mb
green  open   fx-rmlog-2019.02.07             JkoSFfcOSwqYUKCLHwQdzQ   5   1     108852            0     91.5mb         45.6mb
green  open   dfx-syslog-2019.12.17           TVKen3a7QGWoL_VIsbAIXw   5   1          6            0       88kb           44kb
green  open   dfx-rmlog-2019.03.12            jh2M_A3kSrCD62VyeBilrA   5   1       3954            0      2.4mb          1.2mb
green  open   fx-syslog-2019.03.15            PZ0UK0LnThuopOqTb1S_Ng   5   1         10            0    166.8kb         83.4kb
green  open   dfx-rmlog-2019.03.08            DuwyUMFUQymcvBezirxb4g   5   1        322            0      1.3mb        714.7kb
green  open   dfx-rmlog-2019.03.11            30x08g-lTgOOKM_7uAKX-Q   5   1       3157            0      2.1mb        993.8kb
green  open   dfx-rmlog-2019.02.17            _UPtPhVlT4u_GqhU7VNUpw   5   1       2783            0      5.4mb          2.8mb
green  open   dfx-rmlog-2019.02.08            Zo6qIutHQ0WP270kw6hf4Q   5   1         79            0    769.4kb        384.7kb
green  open   dfx-rmlog-2019.03.07            UHCzXgxlQ5C1xSDcCYI9KQ   5   1        205            0      1.1mb        580.4kb
green  open   fx-syslog-2019.03.13            MRjCrvJaTFui6rquFLqN4Q   5   1   13888539            0      5.1gb          2.5gb
green  open   .monitoring-kibana-6-2019.03.08 tvei3n99RveEV1SvN5qhOQ   1   1      17274            0      6.3mb          3.1mb
green  open   dfx-syslog-2019.03.09           pbFqf950RcWzsQQsSIQJwQ   5   1     867684            0    346.5mb        173.4mb
green  open   fx-syslog-2019.03.01            1o6kIuY-SNGk_whIStK6bw   5   1   14953904            0      5.8gb          2.9gb
green  open   .monitoring-kibana-6-2019.03.10 raRvGLxVRaaDFx8PgVWGSg   1   1      17274            0      6.1mb            3mb
green  open   fx-syslog-2019.02.13            BoDbE8XKRUyHI34Xghoq-w   5   1   25967549            0     20.5gb         10.2gb
green  open   dfx-rmlog-2019.02.24            DvFTYcCER2i49cVlCiRvmg   5   1         13            0    305.3kb        152.6kb
green  open   fx-syslog-2019.02.28            6Y3786LIQYaiZGC-m6sFHA   5   1   13656846            0      5.5gb          2.7gb
green  open   dfx-syslog-2019.02.14           7gyTk-XPQ7CdTTmmm54zGw   5   1   14040344            0     16.1gb            8gb
green  open   fx-rmlog-2019.02.24             SbIFowN9SZiGltyX2XPNcg   5   1     219521            0    123.1mb         61.4mb
green  open   dfx-syslog-2019.03.13           nNxrgtA9RamhuBgIU6QIHw   5   1    1007542            0    396.4mb        198.5mb
green  open   dfx-rmlog-2019.03.03            HOuqfEdOTXef2Vjz__g-Iw   5   1         16            0    339.2kb        169.6kb
green  open   dfx-syslog-2019.01.25           aztEsOKBSMqb7ZK9E-EqFg   5   1    2365024            0      1.4gb        749.7mb

使用通配符也可以像下面一样工作:

[root@elastic_dev ~]# curl -s -XGET http://127.0.0.1:9200/_cat/indices?v | awk '$9 == "15.6gb" {print $0}'
green  open   dfx-syslog-2019.02.12           ZkZKzeUsQJKod_2JDiIOGw   5   1   13203227            0     15.6gb          7.8gb
green  open   dfx-syslog-2019.02.11           wivt1yfhT5qhjbgF1Iog_Q   5   1   13223543            0     15.6gb          7.8gb

[root@elastic_dev  ~]# curl -s -XGET http://127.0.0.1:9200/_cat/indices?v | awk '{if ($9 ~ /15.6gb/) print $0}'
green  open   dfx-syslog-2019.02.12           ZkZKzeUsQJKod_2JDiIOGw   5   1   13203227            0     15.6gb          7.8gb
green  open   dfx-syslog-2019.02.11           wivt1yfhT5qhjbgF1Iog_Q   5   1   13223543            0     15.6gb          7.8gb

我正在尝试获取第9列等于或大于[root@elastic_dev ~]# curl -s -XGET http://127.0.0.1:9200/_cat/indices?v | awk '{if ($9 ~ /^15.*gb/) print $0}' green open dfx-syslog-2019.02.13 EfNnTK1lQNm5-SG3DCSqQw 5 1 13378826 0 15.8gb 7.9gb green open dfx-syslog-2019.02.12 ZkZKzeUsQJKod_2JDiIOGw 5 1 13203227 0 15.6gb 7.8gb green open dfx-syslog-2019.02.10 -qL7Cz2tTAKNBm8gtS8MZw 5 1 13000846 0 15.2gb 7.6gb green open dfx-syslog-2019.02.11 wivt1yfhT5qhjbgF1Iog_Q 5 1 13223543 0 15.6gb 7.8gb green open dfx-syslog-2019.02.15 azQye17nSpKDnVSSHjVAuw 5 1 13360599 0 15.8gb 7.9gb 的行。

4 个答案:

答案 0 :(得分:5)

假设您不会在$9中看到太字节(或更大)大小的数字,这是awk,大小大于等于10.5GB。根据需要调整MIN

awk 'BEGIN { MIN=10.5 } $9 ~ /gb$/ { siz=0.0+$9; if(siz >= MIN) print; }'

答案 1 :(得分:4)

尝试一下:

$ awk 'substr($9,1,index($9,"gb")-1) + 0.0 >= 10' file
green  open   fx-syslog-2019.02.12            jbv1mtuET3e8ps2jrJfpjQ   5   1   25964532            0     19.2gb          9.6gb
green  open   dfx-syslog-2019.02.13           EfNnTK1lQNm5-SG3DCSqQw   5   1   13378826            0     15.8gb          7.9gb
green  open   fx-syslog-2019.02.23            WHDwz10jTWibFfKaAdPT0A   5   1   24857467            0     10.6gb          5.3gb
green  open   dfx-syslog-2019.02.12           ZkZKzeUsQJKod_2JDiIOGw   5   1   13203227            0     15.6gb          7.8gb
green  open   dfx-syslog-2019.02.10           -qL7Cz2tTAKNBm8gtS8MZw   5   1   13000846            0     15.2gb          7.6gb
green  open   fx-syslog-2019.02.14            wNMa0id5SkuxnkFdmiG-PA   5   1   19583849            0     14.2gb          7.1gb
green  open   dfx-syslog-2019.02.16           PoFhIj5OTYSsZPxyN4rgsw   5   1   12343056            0     13.4gb          6.7gb
green  open   dfx-syslog-2019.02.11           wivt1yfhT5qhjbgF1Iog_Q   5   1   13223543            0     15.6gb          7.8gb
green  open   dfx-syslog-2019.02.15           azQye17nSpKDnVSSHjVAuw   5   1   13360599            0     15.8gb          7.9gb
green  open   fx-syslog-2019.02.13            BoDbE8XKRUyHI34Xghoq-w   5   1   25967549            0     20.5gb         10.2gb
green  open   dfx-syslog-2019.02.14           7gyTk-XPQ7CdTTmmm54zGw   5   1   14040344            0     16.1gb            8gb

将您产生的输出用作file内容。
它还假定没有比gb高的单元,否则我们需要对其进行改进。

它使用substr提取卷号,并且index提供了第三个扩展 length ,它们在{{1 }},并且此位置仅比数字部分的长度多1,因此请减去gb
由于提取的 number 实际上是一个字符串,因此将其添加到$9会将结果转换为浮点数,然后使用该数字与1进行比较,从而得到一个< em> boolean 。
并且 boolean 用作条件,并且没有块的条件将隐含0.0

考虑更高的单位并更加灵活:

10

这实际上是计算字节数,并与 bytes 中的 10gb 进行比较。
它涵盖从{print $0}awk 'BEGIN{s="kmgtp";q[""]=1;for(i=1;i<=length(s);i++)q[substr(s,i,1)]=1024^i;} {n=u=$9;gsub(/[^.0-9]*/,"",n);gsub(/[0-9.b]*/,"",u);} (n+0.0) * q[u] >= 10 * q["g"] ' 的范围,如果需要,您可以进一步添加其他内容:)
b是用于保存不同单元索引的字节数的数组/哈希。例如pb

答案 2 :(得分:1)

另一个awk

 awk ' { x=$0 } sub("gb","",$9) && $9*1.0 >10.0 { print x } '

答案 3 :(得分:1)

如果您想使用正则表达式解决方案尝试Perl

Subregion

结果

 perl -lane ' print if $F[8]=~/([\d.]+)gb/ and $1>10 ' pygo.dat