0

when i type this command /usr/local/afs7/bin/afs_paftools -a about.afs | grep TOTAL_DOCUMENTS

I get a result

TOTAL_DOCUMENTS = 74195

How i can extract the integer number(74195) after = using grep command

2 Answers 2

2

One way is to use grep:

$ echo "TOTAL_DOCUMENTS = 74195" | grep -o '[0-9]\+'
74195

or since you know, that it's the last field, use awk:

$ echo "TOTAL_DOCUMENTS = 74195" | awk '{print $NF}'
74195

or just use awk for the lot:

your-command -a about.afs | awk '/TOTAL_DOCUMENTS/{print $NF}'
Sign up to request clarification or add additional context in comments.

Comments

0

If there are no space:

TOTAL_DOCUMENTS=74195

Use this awk

echo "TOTAL_DOCUMENTS=74195" | awk -F= '{print $NF}'
74195

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.