www.delorie.com/gnu/docs/sed/sed_17.html   search  
 
Buy the book!


sed, a stream editor

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.4 Print bash Environment

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

 
#!/bin/sh

set | sed -n '
:x

# if no occurrence of "=()" print and load next line
# 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="() "
h

# if the next line has a brace, we quit because
# nothing comes after functions
n
/^{/ q

# print the old line
x; p

# work on the new line now
x; bx
'


  webmaster   donations   bookstore     delorie software   privacy  
  Copyright © 2003   by The Free Software Foundation     Updated Jun 2003  

Please take a moment to fill out this visitor survey
You can help support this site by visiting the advertisers that sponsor it! (only once each, though)