X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=usr_share_grml%2Fzsh%2Ffunctions%2Flinenr;fp=usr_share_grml%2Fzsh%2Ffunctions%2Flinenr;h=20d3862c86a1d578eef35ff352b8b8d85351f35b;hb=2b851312434213e81b0ecb5d0478d07fd4b045e8;hp=0000000000000000000000000000000000000000;hpb=8c93e85d2261599ea73acd5655b2bc84ad42f4e0;p=grml-etc-core.git diff --git a/usr_share_grml/zsh/functions/linenr b/usr_share_grml/zsh/functions/linenr new file mode 100644 index 0000000..20d3862 --- /dev/null +++ b/usr_share_grml/zsh/functions/linenr @@ -0,0 +1,21 @@ +# Print a specific line of file(s). +emulate -L zsh + +if [ $# -lt 2 ] ; then + print "Usage: linenr [,] " ; return 1 +elif [ $# -eq 2 ] ; then + local number=$1 + local file=$2 + command ed -s $file <<< "${number}n" +else + local number=$1 + shift + for file in "$@" ; do + if [ ! -d $file ] ; then + echo "${file}:" + command ed -s $file <<< "${number}n" 2> /dev/null + else + continue + fi + done | less +fi