Browse Source

a more advanced head

git-svn-id: http://www.rocklinux.org/svn/rock-linux/trunk@1370 c5f82cb5-29bc-0310-9cd0-bff59a50e3bc
rocklinux
Rene Rebe 21 years ago
parent
commit
d14daede21
2 changed files with 23 additions and 11 deletions
  1. +2
    -11
      target/bootdisk/build_stage2.sh
  2. +21
    -0
      target/bootdisk/head

+ 2
- 11
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

+ 21
- 0
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 "" $*

Loading…
Cancel
Save