Rather than look in the operating system, look at scripts used for building the programs.
Any autoconf-generated configure
script contains sed-scripts, and itself generates a script which contains a sed-script. That substitutes values for names in the template files such as Makefile.in
to produce a Makefile
. For example (conveniently found with web search) this chunk of a config.status
file for distcc illustrates how sed
is used:
while :; do
case $as_dir in #(
*\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
*) as_qdir=$as_dir;;
esac
as_dirs="'$as_qdir' $as_dirs"
as_dir=`$as_dirname -- "$as_dir" ||
$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$as_dir" : 'X\(//\)[^/]' \| \
X"$as_dir" : 'X\(//\)$' \| \
X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X"$as_dir" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
}
/^X\(\/\/\)[^/].*/{
s//\1/
q
}
/^X\(\/\/\)$/{
s//\1/
q
}
/^X\(\/\).*/{
s//\1/
q
}
s/.*/./; q'`
test -d "$as_dir" && break
done
Aside from autoconf, scripting is useful for other aspects of building (and installing) programs. The manlinks.sed
script in ncurses is long enough to be considered as a program.
You can of course use grep
to find sed
used. However, it is common to use a ".sed" file-suffix for standalone scripts. "locate .sed"
finds those.
In a quick check on my machine, there is one extremely long sed script (more than two thousand lines, counting comments):
#!/usr/5bin/sed -nf
#r
#r sokoban.sed - aurlio marinho jargas <aurelio@verde666.org>
#r Changes by Gunnar Ritter, October 2002.
#r
#r Sccsid @(#)sokoban.sed 1.7 (gritter) 10/12/03
#r
#r motivated by reading the amazing Adventure (Colossal Cave) history
#r <http://www.rickadams.org/adventure/a_history.html>
#r GPL levels took from Mike Sharpe's sokoban.vim <http://vim.sourceforge.net>
#r
#r IMPORTANT
#r this script has terminal control chars, so you must DOWNLOAD this
#r file. just copy/paste or printing it to a file (lynx) will NOT work.
#r
#r THE GAME
#r you know sokoban. everybody knows sokoban.
(Someone made a colorized version of it).
That is one of three scripts used for testing sed
in the "heirloom tools":
-rw-r--r-- 1 tom 285 Oct 6 2002 makefile
-rw-r--r-- 1 tom 3664 Oct 11 2003 hanoi.sed
-rw-r--r-- 1 tom 2338 Oct 11 2003 math.sed
-rw-r--r-- 1 tom 42552 Oct 11 2003 sokoban.sed
Likewise, the sed program has an interesting example:
#!/bin/sed -nf
# dc.sed - an arbitrary precision RPN calculator
# Created by Greg Ubben <gsu@romulus.ncsc.mil> early 1995, late 1996
#
# Dedicated to MAC's memory of the IBM 1620 ("CADET") computer.
# @(#)GSU dc.sed 1.1 06-Mar-1999 [non-explanatory]
#
# Examples:
# sqrt(2) to 10 digits: echo "10k 2vp" | dc.sed
# 20 factorial: echo "[d1-d1<!*]s! 20l!xp" | dc.sed
# sin(ln(7)): echo "s(l(7))" | bc -c /usr/lib/lib.b | dc.sed
# hex to base 60: echo "60o16i 6B407.CAFE p" | dc.sed
# tests most of dc.sed: echo 16oAk2vp | dc.sed
#
# To debug or analyze, give the dc Y command as input or add it to
# embedded dc routines, or add the sed p command to the beginning of
# the main loop or at various points in the low-level sed routines.
# If you need to allow [|~] characters in the input, filter this
# script through "tr '|~' '\36\37'" first (or use dc.pl).
Likewise, there is a page with a colorized version of dc.sed
However, autoconf and build-scripts are where you might find productive use of sed
.
Further reading:
sed
, you can look at some of the scripts ininfo sed
. you could look at math.sed. i seriously doubt youll find any examples worth following in any scripts distributed by default with linux distributions. you would find some, though, if you looked hard at a BSD Ports tree and its constituentmake
files. – mikeserv Oct 24 '15 at 06:40