Skip to content
Browse files

Added utility stripinit.sh which strips the first n fields from every…

… line. Usefull for removing the initial states
  • Loading branch information...
1 parent d0e89e4 commit 2bea121f4e074dbd754469613d9d02a64b58f885 @dchaws committed Jul 26, 2011
Showing with 18 additions and 0 deletions.
  1. +18 −0 stripinit.sh
View
18 stripinit.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+# Strips the first $1 fields from every line
+
+# E.g.
+# echo 1 2 3 4 5 6 7 8 9 10 | ./stripinit.sh 3
+# Outputs: 4 5 6 7 8 9 10
+
+if [[ $# -ne 1 ]]
+then
+ echo "Usage:"
+ echo "./stripinit.sh <number of fields to strip>"
+ echo ""
+ echo "Reads from standard input."
+ exit 0
+fi
+
+awk '{ for (i='$1'+1;i<=NF;i++) { printf("%s ",$i); } printf("\n");}'

0 comments on commit 2bea121

Please sign in to comment.
Something went wrong with that request. Please try again.