Skip to content

Instantly share code, notes, and snippets.

@Gabriel-p
Last active August 29, 2015 14:09
Show Gist options
  • Save Gabriel-p/681fce310855a05f0e4b to your computer and use it in GitHub Desktop.
Save Gabriel-p/681fce310855a05f0e4b to your computer and use it in GitHub Desktop.
Fill empty spaces in aligned columns file
# See:
# http://unix.stackexchange.com/questions/164207/insert-missing-string-in-multiple-ordered-columns
#
# The string of numbers after 'FIELDWIDTHS' indicate the end position of each column in the file
# The column numbers should be counted *starting from 0*.
gawk -vFIELDWIDTHS="4 7 4 6 8 8 6 8 8 8 7 5 4" -vOFS= '{for (i=1;i<=NF;i++) sub(" $","--",$i);}1' file.dat > out.dat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment