From 37452c8411ddc925e50028a4b8e036365b17818f Mon Sep 17 00:00:00 2001 From: Dustin Kirkland Date: Wed, 18 Jun 2014 12:58:06 -0500 Subject: [PATCH] * debian/links, usr/bin/col1, usr/share/man/man1/col1.1: - move the col1..col9 utilities over from bikeshed - super handy, minimal way of awking out a particular column --- debian/changelog | 3 +++ debian/links | 18 ++++++++++++++++++ usr/bin/col1 | 29 +++++++++++++++++++++++++++++ usr/share/man/man1/col1.1 | 37 +++++++++++++++++++++++++++++++++++++ 4 files changed, 87 insertions(+) create mode 100755 usr/bin/col1 create mode 100644 usr/share/man/man1/col1.1 diff --git a/debian/changelog b/debian/changelog index a65afe03..86c26a16 100644 --- a/debian/changelog +++ b/debian/changelog @@ -10,6 +10,9 @@ byobu (5.81) unreleased; urgency=medium status.1: - move the wifi-status command to byobu, from bikeshed - fantastic demonstration of byobu split screens + * debian/links, usr/bin/col1, usr/share/man/man1/col1.1: + - move the col1..col9 utilities over from bikeshed + - super handy, minimal way of awking out a particular column -- Dustin Kirkland Mon, 28 Apr 2014 09:36:59 -0700 diff --git a/debian/links b/debian/links index f0ea7634..5985f453 100644 --- a/debian/links +++ b/debian/links @@ -1 +1,19 @@ usr/share/byobu/pixmaps/byobu.svg usr/share/icons/hicolor/scalable/apps/byobu.svg +usr/bin/col1 usr/bin/col2 +usr/bin/col1 usr/bin/col3 +usr/bin/col1 usr/bin/col4 +usr/bin/col1 usr/bin/col5 +usr/bin/col1 usr/bin/col6 +usr/bin/col1 usr/bin/col7 +usr/bin/col1 usr/bin/col8 +usr/bin/col1 usr/bin/col9 +usr/bin/col1 usr/bin/NF +/usr/share/man/man1/col1.1.gz /usr/share/man/man1/col2.1.gz +/usr/share/man/man1/col1.1.gz /usr/share/man/man1/col3.1.gz +/usr/share/man/man1/col1.1.gz /usr/share/man/man1/col4.1.gz +/usr/share/man/man1/col1.1.gz /usr/share/man/man1/col5.1.gz +/usr/share/man/man1/col1.1.gz /usr/share/man/man1/col6.1.gz +/usr/share/man/man1/col1.1.gz /usr/share/man/man1/col7.1.gz +/usr/share/man/man1/col1.1.gz /usr/share/man/man1/col8.1.gz +/usr/share/man/man1/col1.1.gz /usr/share/man/man1/col9.1.gz +/usr/share/man/man1/col1.1.gz /usr/share/man/man1/NF.1.gz diff --git a/usr/bin/col1 b/usr/bin/col1 new file mode 100755 index 00000000..29840baf --- /dev/null +++ b/usr/bin/col1 @@ -0,0 +1,29 @@ +#!/bin/sh -e +# +# col1..col9 - handy hack to print a column from standard in +# +# Copyright (C) 2010 Dustin Kirkland +# +# Authors: +# Dustin Kirkland +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +if [ $# -gt 0 ]; then + ifs='-F'"$1" + shift || true +else + ifs="-F " +fi +b=$(basename $0) +awk "$ifs" '{print $'${b#col}'}' "$@" diff --git a/usr/share/man/man1/col1.1 b/usr/share/man/man1/col1.1 new file mode 100644 index 00000000..76745f92 --- /dev/null +++ b/usr/share/man/man1/col1.1 @@ -0,0 +1,37 @@ +.TH col1 1 "27 Sep 2010" byobu "byobu" +.SH NAME +col1 .. col9, NF \- awk and print a column (based on the name of the program, 1-9) + +.SH SYNOPSIS +.BI "col1 [SEPARATOR]" + +.SH DESCRIPTION +\fBcol1\fP is a simple script that conveniently splits and prints a given column, where the column to print is the name of the script program you're running (col1-col9). col2-col9 are symlinks to col1; their behavior simply changes based on the name called. + +\fBNF\fP can be used to print the last field. + +The program takes one optional argument, the input field separator (whitespace, by default). + +.SH EXAMPLES +Rather than: + mount | awk '{print $3}' + +Try: + mount | col3 + +Instead of: + cat /etc/passwd | awk \-F":" '{print $7}' + +You can just do: + cat /etc/passwd | col7 : + +Or + cat /etc/passwd | NF : + +.SH SEE ALSO +\fBawk\fP(1)\fP + +.SH AUTHOR +This manpage and the utility was written by Dustin Kirkland for Ubuntu systems (but may be used by others). Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 3 published by the Free Software Foundation. + +On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL, or on the web at \fIhttp://www.gnu.org/licenses/gpl.txt\fP.