Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Welcome to LinuxQuestions.org, a friendly and active Linux Community.

You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!

Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.

If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.

Having a problem logging in? Please visit this page to clear all LQ-related cookies.

Introduction to Linux - A Hands on Guide

This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.

Why do you escape the pipe? Seems to have some strange nuances. GNU BRE adds alteration by escape. You originally had '.\| ', which means any character except new line (. == [^n]) or space.

Technically, '.\|' does not make sense to me, so I am not sure why it works. I'd prefer to avoid regex if possible.

why escape the pipe?

because the pipe has actual significance in a Linux shell

Code:

ls | less

and

Code:

ls \| less

are two different commands

one pipes the output of ls into the less command
the other tries to list the file named | and a file named less
the pipe takes output of one command and uses it as the input for the next, unless escaped.
understand?

Why do you escape the pipe? Seems to have some strange nuances. GNU BRE adds alteration by escape. You originally had '.\| ', which means any character except new line (. == [^n]) or space.

Technically, '.\|' does not make sense to me, so I am not sure why it works. I'd prefer to avoid regex if possible.

I don't see why you need the '-b' flag, it sees to work without for me... Can you give me an example of a file where it doesn't work?

With regards to the pipe, it's an "or": there's a space after the pipe, so it's saying "match anything except a newline". If you didn't escape it, it would literally be matching the sequence "any character, then |, then a space" which isn't what you want.

one pipes the output of ls into the less command
the other tries to list the file named | and a file named less
the pipe takes output of one command and uses it as the input for the next, unless escaped.
understand?

I understand pipe redirection. The escaped pipe symbol is part of the regex expression and not part of the bash shell.

Quote:

On top of what POSIX BRE provides as described above, the GNU extension provides \? and \+ as an alternative syntax to \{0,1\} and \{1,\}. It adds alternation via \|, something sorely missed in POSIX BREs.