commit 5c70560ba956ab0abdefb5135c43d52bd6129c79 parent 36f73c3cd01bf64f4f30a9a08acebbfed8767dda Author: Ed van Bruggen <edvb@uw.edu> Date: Tue, 22 Jan 2019 23:15:30 -0800 Add body script Diffstat:
_data/projects.yml | | | 2 | ++ |
projects/body.md | | | 22 | ++++++++++++++++++++++ |
2 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/_data/projects.yml b/_data/projects.yml @@ -22,6 +22,8 @@ main: - name: 'tim' desc: 'extendable personal assistant' - header: 'scripts' + - name: 'body' + desc: 'print the body of a file' - name: 'ed' desc: 'commands revolving around $EDITOR' - name: 'sett' diff --git a/projects/body.md b/projects/body.md @@ -0,0 +1,22 @@ +--- +title: body +description: print the body of a file +--- + +```bash +#!/usr/bin/env bash + +# body: print the body of a file +# +# if only two arguments are given print the file given by the first at the line +# number from the second. If a third argument is given print until that line. + +if [[ $# == 2 ]]; then + sed -n $2p $1 +elif [[ $# == 3 ]]; then + sed -n $2,$3p $1 +else + echo "usage: body FILE LINE [UNTIL]" + exit 1 +fi +```