-
-
Save apuignav/54cd2f75df01615172c0 to your computer and use it in GitHub Desktop.
Useful scripts from Christian Neukirchen's Summer of Scripts (http://chneukirchen.org/blog/)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/perl | |
| # From http://chneukirchen.org/blog/archive/2013/07/summer-of-scripts-f.html | |
| my $field = shift or usage(); | |
| $field -= 1 if $field > 0; | |
| while (<>) { | |
| chomp; | |
| my @f = split; | |
| print $f[$field], "\n"; | |
| } | |
| sub usage { | |
| print STDERR "$0 fieldnumber\n"; | |
| exit 1; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # total - sum up numbers in a column | |
| # From http://chneukirchen.org/blog/archive/2013/07/summer-of-scripts-total.html | |
| expr "$1" : -F >/dev/null && F=$1 && shift | |
| exec awk $F -v f=${1:-1} '{s+=$f} END{print s}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment