From d14daede21218a3ee2cf1f8d149f00ca8baa842c Mon Sep 17 00:00:00 2001 From: Rene Rebe Date: Wed, 10 Sep 2003 10:04:20 +0000 Subject: [PATCH] a more advanced head git-svn-id: http://www.rocklinux.org/svn/rock-linux/trunk@1370 c5f82cb5-29bc-0310-9cd0-bff59a50e3bc --- target/bootdisk/build_stage2.sh | 13 ++----------- target/bootdisk/head | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 11 deletions(-) create mode 100644 target/bootdisk/head diff --git a/target/bootdisk/build_stage2.sh b/target/bootdisk/build_stage2.sh index e961113f9..26036ed23 100644 --- a/target/bootdisk/build_stage2.sh +++ b/target/bootdisk/build_stage2.sh @@ -157,17 +157,8 @@ for i in gui_text mod_install mod_packages mod_gas default ; do cp -v ../2nd_stage/etc/stone.d/$i.sh etc/stone.d done # -echo_status "Creating head replacement script." -cat << 'EOT' > bin/head -#!/bin/sh -m=10 -if echo "$1" | grep -- "-[0-9]\+" > /dev/null ; then - m="${1#-}" - shift -fi -exec grep -m$m "" $* -EOT -chmod +x bin/head +echo_status "Copy head replacement script." +cp $base/target/$target/head bin/head ; chmod +x bin/head # echo_status "Creating links for identical files." while read ck fn diff --git a/target/bootdisk/head b/target/bootdisk/head new file mode 100644 index 000000000..f08a35ba3 --- /dev/null +++ b/target/bootdisk/head @@ -0,0 +1,21 @@ +#!/bin/sh + +m=10 + +useage () { + echo "Usage: head [OPTION]... [FILE]..." + echo -e "\t-n,-[0-9]+\tprint first NUMBER lines instead of first 10" + exit 1 +} + +while [ "$1" ] ; do + case "$1" in + -n) m="$2" ; shift ; shift ;; + -[0-9]*) m=${1#-}; shift ;; + -*) useage ;; + *) break; + esac +done + +exec grep -m$m "" $* +