Next: , Previous: Rename files to lower case, Up: Examples

4.4 Print bash Environment

This script strips the definition of the shell functions from the output of the set Bourne-shell command.

     set | sed -n '
     # if no occurrence of ‘=()’ print and load next line
     /=()/! { p; b; }
     / () $/! { p; b; }
     # possible start of functions section
     # save the line in case this is a var like FOO="() "
     # if the next line has a brace, we quit because
     # nothing comes after functions
     /^{/ q
     # print the old line
     x; p
     # work on the new line now
     x; bx