Skip to content

Instantly share code, notes, and snippets.

@aprell
Created November 22, 2017 17:46
Show Gist options
  • Select an option

  • Save aprell/e0b06edf0278c47241a292011e2e97fe to your computer and use it in GitHub Desktop.

Select an option

Save aprell/e0b06edf0278c47241a292011e2e97fe to your computer and use it in GitHub Desktop.
Reminder to strip off carriage returns
A B C
1 2 3
4 5 6
7 8 9
#!/usr/bin/awk -f
BEGIN {
i = 0
}
NR > 1 {
A[i] = $1
B[i] = $2
C[i] = $3
i++
}
END {
for (j = 0; j < i; j++) {
print "x", A[j], B[j], C[j], "y"
}
}
@aprell

aprell commented Nov 22, 2017

Copy link
Copy Markdown
Author

This is what we want:

> ./filter.awk data.txt
x 1 2 3 y
x 4 5 6 y
x 7 8 9 y

This is what we get:

> ./filter.awk data.txt
 y1 2 3
 y4 5 6
 y7 8 9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment