-1

My command output is like this

                                Name: SLP_DCEMA100BAK01.1M__GBLON500BAK04.6M

 Operation  1                Use for: 0 (backup)

                             Storage: stu_disk_dcema100bak01

                     Retention Level: 3 (1 month)

 Operation  2                Use for: 1 (duplication)

                             Storage: stu_cc_gblon500bak04

                     Retention Level: 6 (6 months)

I want to print only those part that comes after ":"

Expected output is Like below

SLP_DCEMA100BAK01.1M__GBLON500BAK04.6M

0 (backup)

stu_disk_dcema100bak01

3 (1 month)

1 (duplication)

stu_cc_gblon500bak04

6 (6 months)
1

To remove everything up through (and including) the last : on each line, use

sed 's/.*://'

For example,

your_command | sed 's/.*://'

If your data (the part after the label, which you want to keep) might contain a :, you want to remove everything up through the first : in the line:

sed 's/^[^:]://'

If you have a space after the colon (as shown in your example) and you want to remove that, too, just add a space after the colon in the command:

sed 's/.*: //'

or

sed 's/^[^:]: //'
0
awk -F: '{sub(/^ /,"",$2);print $2}' file

SLP_DCEMA100BAK01.1M__GBLON500BAK04.6M

0 (backup)

stu_disk_dcema100bak01

3 (1 month)

1 (duplication)

stu_cc_gblon500bak04

6 (6 months)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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