Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Looks like "avprobe" writes output to STDERR, which is why your grep isn't doing anything. And "lsb_release" also writes part of it's output, specifically the "No LSB modules are available." line to STDERR.
Why does the output of your first command also include 'No LSB modules are available.' when only the line containing 'Release' should be shown?
Do you have 'grep' aliased to something?
Perhaps the output from 'alias' will help.
My alias output:
Code:
...
alias ftp='ncftp -d15'
alias grep='grep --color=auto'
alias h='history 10'
...
I extracted the following from my current Bash textbook, this will convenience future learners who encounter the same problem.
Chapter 20. I/O Redirection
p 371:
There are always three default files [104] open, stdin (the keyboard), stdout (the screen), and stderr
(error messages output to the screen). These, and any other open files, can be redirected.
...
Each open file gets assigned a file descriptor. [105] The file descriptors for stdin, stdout, and stderr
are 0, 1, and 2, respectively.
...
p372:
2>&1
# Redirects stderr to stdout.
# Error messages get sent to same place as standard output.
>>filename 2>&1
bad_command >>filename 2>&1
# Appends both stdout and stderr to the file "filename" ...
2>&1 | [command(s)]
bad_command 2>&1 | awk '{print $5}'
# found
# Sends stderr through a pipe.
# |& was added to Bash 4 as an abbreviation for 2>&1 |.
i>&j
# Redirects file descriptor i to j.
# All output of file pointed to by i gets sent to file pointed to by j.
>&j
# Redirects, by default, file descriptor 1 (stdout) to j.
# All stdout gets sent to file pointed to by j.
Footnotes:
[104] By convention in UNIX and Linux, data streams and peripherals (device files) are treated as files, in a
fashion analogous to ordinary files.
[105] A file descriptor is simply a number that the operating system assigns to an open file to keep track of it. Consider it a simplified type of file pointer. It is analogous to a file handle in C.
Last edited by andrew.comly; 04-27-2016 at 02:51 AM.
Reason: clarity
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.