bash-based Unix Shell Script: Difference between revisions

From GM-RKB
Jump to navigation Jump to search
 
m (Text replacement - ". ----" to ". ----")
 
(8 intermediate revisions by the same user not shown)
Line 2: Line 2:
* <B>Context:</B>
* <B>Context:</B>
** It cam make use of a [[Unix Utility]].
** It cam make use of a [[Unix Utility]].
* <B><U>See:</U></B> [[perl-based Script]].
* <B>See:</B> [[perl-based Script]].
 
----
----
----
----
==References==
 
== References ==
 
* http://www.gnu.org/software/bash/manual/bashref.html
* http://www.gnu.org/software/bash/manual/bashref.html
* http://tldp.org/LDP/abs/html/
* http://tldp.org/LDP/abs/html/


----
----
== Examples ==
== Examples ==


; Redirecting stderr to stdout (and stdout to stderr)
; Redirecting stderr to stdout (and stdout to stderr)
<pre>
<pre>
$ (time sleep 1) 2>&1           | grep real
$ (time sleep 1) 2>&1         | grep real
$ (time sleep 1) 3>&1 1>&2 2>&3 | grep real
$ (time sleep 1) 3>&1 1>&2 2>&3 | grep real
</pre>
</pre>
Line 23: Line 27:
$ while [ "$loop" == "true" ]; do sleep 2; \
$ while [ "$loop" == "true" ]; do sleep 2; \
     up=`uptime | awk '{print $8}'|sed "s/,//"| sed "s/\.//" | bc`; \
     up=`uptime | awk '{print $8}'|sed "s/,//"| sed "s/\.//" | bc`; \
     echo "$up "; if [ $up -le 7 ]; then loop="false"; fi; done
     echo "$up "; if [ $up -le 7]; then loop="false"; fi; done
</pre>
</pre>


----
----
__NOTOC__
__NOTOC__
[[Category:Concept]]
[[Category:Concept]]

Latest revision as of 03:30, 24 September 2021

A bash-based Unix Shell Script is a Unix Shell Script based on the bash Shell Program.



References


Examples

Redirecting stderr to stdout (and stdout to stderr)
$ (time sleep 1) 2>&1          | grep real
$ (time sleep 1) 3>&1 1>&2 2>&3 | grep real
Looping
$ loop="true" ;
$ while [ "$loop" == "true" ]; do sleep 2; \
    up=`uptime | awk '{print $8}'|sed "s/,//"| sed "s/\.//" | bc`; \
    echo "$up "; if [ $up -le 7]; then loop="false"; fi; done