AloneInTheDark AloneInTheDark - 2 years ago 70
Bash Question

Get lines that end with "$" in a text file

I have an output like this:

a/foo bar /
b/c/foo sth /xyz
cc/bar ghj /axz/byz

What i want is just this line:

a/foo bar /

To be more clear, I want those line ending with a specific string. I want to
lines that have a
character at their last column.

Answer Source

You can use $ like this:

$ grep '/$' file
a/foo bar /

As $ stands for end of line, /$ matches those lines whose last character is a /.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download