0

I am currently using this below command for getting the total snapshot usage of the storage, but this will only show the value in G not in T:

# isi_classic snapshot usage | tail -n 1 | egrep -o "[+-]?[0-9]+[.]?[0-9]([eE][+-])?[0-9]G"
621G

Is there any way to match both G & T in one command and the get the exact output?

# isi_classic snapshot usage
[snapid 1653, delete pending]                        0     n/a (R)    0.00% (T)
ifs_daily-s1-nov01_20            262G     n/a (R)    0.46% (T)
ifs_weeky-s1-nov01_20            176G     n/a (R)    0.31% (T)

                                               18T     n/a (R)   31.37% (T)

Actual output is as shown below

 isi_classic snapshot usage | tail -n 1
                                                  621G     n/a (R)    1.08% (T)
  • 1
    Show the output of isi_classic snapshot usage. Show your expected output after processing. – Sparhawk Jun 13 '17 at 9:58
  • @Sparhawk the output is very big. let me tail it for you. – Poo Jun 13 '17 at 10:20
  • I have added the command, sorry missing it. – Poo Jun 13 '17 at 10:29
  • Have you tried egrep "\(G|T\)"? this way, you would get both G and T. – ss_iwe Jun 13 '17 at 10:31
  • yes i tried but no luck. – Poo Jun 13 '17 at 10:36
1

I don't think grep is necessary here, use awk instead,

isi_classic snapshot usage | tail -1 | awk '{print $1}'

But if you insist on using grep, change the last G to [GT] should work for you:

isi_classic snapshot usage | tail -1 | egrep -o "[+-]?[0-9]+[.]?[0-9]([eE][+-])?[0-9][GT]"

Not the answer you're looking for? Browse other questions tagged or ask your own question.