Never been to CodeSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

Compiling GNU sed 4.1.4 on Mac OS X (See related posts)

path='
/usr/local/bin 
/usr/local/sbin
/usr/local/lib
/usr/local/include
/usr/local/man
/usr/bin
/bin
/usr/sbin
/sbin
'

path="$(printf "%s" "${path// /}" | /usr/bin/tr '\n' ':' | /usr/bin/sed -E 's/^:|:$//g')"

printf "%s\n" "$path" | tr ':' '\n'

export PATH="${path}"


cd ~/Desktop

curl -L -O http://ftp.gnu.org/gnu/sed/sed-4.1.4.tar.gz
cd ~/Desktop/sed-4.1.4

# cf. Compiling GNU coreutils on Mac OS X, 
# http://codesnippets.joyent.com/posts/show/1799
./configure --prefix=/usr/local/gnucoreutils
  
make

/usr/bin/sudo /usr/bin/make install



ls -l /usr/local/gnucoreutils/bin/sed
/usr/local/gnucoreutils/bin/sed --version
man /usr/local/gnucoreutils/man/man1/sed.1

/usr/bin/sudo /bin/ln -is /usr/local/gnucoreutils/bin/sed /usr/local/bin/gnused

# use GNU sed with case insensitive option
echo Tool | sed 's/[Tt]/c/'
echo Tool | gnused 's/t/c/i'


# cf. "Extract title from HTML web page" on http://bosetsu.org/pub/docs/shell_cheatsheet.html
curl -L -s http://codesnippets.joyent.com/posts/show/1835 | \
     gnused -n 's/.*<[tT][iI][tT][lL][eE]>\(.*\)<\/[tT][iI][tT][lL][eE]>.*/\1/p;T;q'

# cf. http://www.pixelbeat.org/cmdline.html
curl -L -s http://codesnippets.joyent.com/posts/show/1835 | \
     gnused -n 's/.*<title>\(.*\)<\/title>.*/\1/ip;T;q'

You need to create an account or log in to post comments to this site.