Bash

Facebook Twitter

Cod

Bourne. Determine If Shell Input is Coming From the Terminal or From a Pipe. Working on a little script the other day I had the need to determine if the input to the script was coming from a pipe or from the terminal.

Determine If Shell Input is Coming From the Terminal or From a Pipe

Seems like a simple enough thing to determine but nothing jumped immediately to mind and a quick internet search didn't help much either. After a bit of pondering I came up with two solutions: the stat command and using information from the proc file system. UNIX BASH scripting. UNIX / Linux Bourne / Bash Shell Scripting Tutorial [ steve-parker.org ] Bashfully Yours, Gem Shortcuts. Bash Process Substitution. In addition to the fairly common forms of input/output redirection the shell recognizes something called process substitution.

Bash Process Substitution

Although not documented as a form of input/output redirection, its syntax and its effects are similar. The syntax for process substitution is: <(list) or >(list) where each list is a command or a pipeline of commands. Discover tput. What is tput?

Discover tput

The tput command initializes and manipulates your terminal session through the terminfo database. Using tput, you can alter several terminal capabilities, such as moving or altering the cursor, changing text properties, and clearing specific areas of the terminal screen. Back to top What is the terminfo database?