Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a file like below.

 1. VMware ESX
 2. SCCM
 3. Healthcare Information Technology
 4. vSphere
 5. Citrix Metaframe
 6. IT Service Management
 7. ITIL
 8. Active Directory
 9. Project Portfolio Management
10. Windows
11. Incident Management
12. Change Management
13. Disaster Recovery
14. Governance
15. Citrix
16. Stakeholder Management
17. Project Delivery
18. IT Operations
19. Infrastructure

I want only the values after . I need only the values like VMWare ESX, SCCM etc to store in an array.

I tried the below command.

echo $line | grep -o -P '.'

But it is giving me characters before dot.

share|improve this question
up vote 4 down vote accepted

To remove the characters before and including the right-most occurrence of a dot followed by a space.

sed 's/.*\. //' < file

If .␣ may appear more than once and you only want to remove up to the first occurrence, the trick is to do:

sed 's/\. /\
/;s/.*\n//' < file

(that is replace the first occurrence with a newline character, and then remove everything up to that newline).

However, in your case,

sed 's/^[^.]*\. //' < file

(remove a leading sequence of non-dot characters followed by a dot and a space).

or even:

cut -c5- < file

(remove the first 4 characters) should be enough.

Using GNU grep with support for recent PCRE:

grep -Po '\. \K.*'
share|improve this answer


sed 's/.*\.\ //' your-file-name

to remove the characters before and including the dot followed by space.

share|improve this answer

In awk:

awk -F'. ' '{$1=""; print $0}' your_file
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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