news
today's howtos
-
HowTo Geek ☛ How to pipe and redirect like a pro in the Linux command line
On Linux, pipes and redirection let you use the output from commands in powerful ways. Capture it in files, or use it as input with other commands. Here’s what you need to know.
What are streams?
Linux, like other Unix-like operating systems, has a concept of streams. Each process has an input stream called stdin, an output stream called stdout, and a stream for errors, called stderr. Linux streams, like streams in the real world, have two endpoints. They have a source or input, and a destination, or output.
The input stream might come from the keyboard to the command, letting you send text such as information or commands to the process. The output stream comes from the command, usually to the terminal window. The stderr stream also writes to the terminal window.
You can redirect streams, and you can pipe them. Redirection means sending the output to somewhere other than the terminal window. Piping means taking the output of one command and using it as the input to another command.
-
HowTo Geek ☛ I finally figured out Vim's "hidden" file system, and it changed everything
I used to shy away from buffers and tabs because the confusing terminology and obscure keyboard shortcuts put me off. But rest assured, learning all about buffers, windows, and tabs has transformed my Vim usage. I now wonder how I ever worked without them!
Getting started with buffers in Vim
First, try to think of a buffer as an open file. Vim lets you open several files at once, which means each gets its own buffer; you can switch between them, and you can display more than one at once.
-
Shell/Bash/Zsh/Ksh
-
HowTo Geek ☛ 3 Bash error-handling patterns I use in every script
Are you learning Bash or wishing to improve error handling in your scripts? The rules governing errors can be a little tricky to understand, so I've put together this bite-sized guide to untangle their mystery.
[...]
The initial pattern I learned—and often the first recommended—is the set -e option. It simply makes your script exit when it detects a non-zero exit code. For those unaware, an exit code is a number returned by all programs on Linux, and when it's non-zero, it's an error. You can see the exit code of the most recently exited process with echo $?.
-