# parse special character in the line

**URL:** https://community.unix.com/t/parse-special-character-in-the-line/268324
**Category:** Shell Programming and Scripting
**Created:** [June 25, 2010, 2:58am UTC](https://community.unix.com/t/parse-special-character-in-the-line/268324 "2010-06-25T02:58:11Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![vijaya2006](https://community.unix.com/letter_avatar/vijaya2006/32/5_5575768a8748004e209b776fc1b2916d.png) [@vijaya2006](https://community.unix.com/u/vijaya2006)
#### Post date: [June 25, 2010, 2:58am UTC](https://community.unix.com/t/parse-special-character-in-the-line/268324/1 "2010-06-25T02:58:11Z")

</div>

Hi all,

I have a file with some module names as below.

Font::AFM  
Data::Grove ---\> libxml-perl  
Net::LDAP ---\> perl-ldap  
DBI  
XML  
....  
...  
....

and so on ...

The file has some lines with the character " --\>" .  
Now how can I cut only the last column of the line wherever "--\>" is found and keep others as it is in its place.

o/p should be like:  
---------------  
Font::AFM  
libxml-perl  
perl-ldap  
DBI  
XML  
...  
...

Is there way other than using using while read line and redirecting the line to some other file? Any simpler means using sed or awk ??

Thanks in advance. :b::b:

---

<div class="post-metadata">

### Author: ![bartus11](https://community.unix.com/user_avatar/community.unix.com/bartus11/32/1418_2.png) [@bartus11](https://community.unix.com/u/bartus11)
#### Post date: [June 25, 2010, 3:05am UTC](https://community.unix.com/t/parse-special-character-in-the-line/268324/2 "2010-06-25T03:05:53Z")

</div>

```nohighlight
awk '/--->/{sub(".*> ","");print;next}1' file

```

---

<div class="post-metadata">

### Author: ![pludi](https://community.unix.com/user_avatar/community.unix.com/pludi/32/1278_2.png) [@pludi](https://community.unix.com/u/pludi)
#### Post date: [June 25, 2010, 3:07am UTC](https://community.unix.com/t/parse-special-character-in-the-line/268324/3 "2010-06-25T03:07:02Z")

</div>

Always the last field?

```nohighlight
awk '{print $NF}' file

```

---

<div class="post-metadata">

### Author: ![dr.house](https://community.unix.com/letter_avatar/dr.house/32/5_5575768a8748004e209b776fc1b2916d.png) [@dr.house](https://community.unix.com/u/dr.house)
#### Post date: [June 25, 2010, 3:08am UTC](https://community.unix.com/t/parse-special-character-in-the-line/268324/4 "2010-06-25T03:08:30Z")

</div>

```nohighlight
sed -i data.file -e 's/.*-> //g'

```

---

<div class="post-metadata">

### Author: ![vijaya2006](https://community.unix.com/letter_avatar/vijaya2006/32/5_5575768a8748004e209b776fc1b2916d.png) [@vijaya2006](https://community.unix.com/u/vijaya2006)
#### Post date: [June 25, 2010, 4:01am UTC](https://community.unix.com/t/parse-special-character-in-the-line/268324/5 "2010-06-25T04:01:19Z")

</div>

Hi bartus11,  
Thanks a lot. It worked for me 🙂
