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. 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.
As you know the 'time' command run programs and summarize system resource usage. Here is a way how you can redirect 'time' command output to file. I would recomend you to go through this page to understand more about 'time' command. e.g. We are executing 'prog.sh' along with 'time' command. UNIX BASH scripting
To gain quick BASH access to your RDocs, add these lines to your ~/.bash_profile (or equivalent):1 Let’s try it out… source ~/.bash_profile gemdoc hpricot Bashfully Yours, Gem Shortcuts
In addition to the fairly common forms of input/output redirection the shell recognizes something called 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. Bash Process Substitution
Discover tput What is 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? The terminfo database on a UNIX system defines terminal and printer attributes and capabilities, including the number of lines and columns for the respective device (for example, terminal and printer) and attributes of text to be sent to the device.