-
-
Notifications
You must be signed in to change notification settings - Fork 315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] ExecForEach: Accurately get columns by index #152
Comments
I'm not sure how this would work, because pipe stages communicate with one another by a stream of bytes—or lines—not discrete values. Where would The best thing to do here might be to write a |
Go template supports slices accessed by index, and I used this function to achieve awk's columns acquisition, like $1, $2, corresponding to |
Great, so is what you're really asking for that |
Yep~ , and the data of multiple columns can be obtained through index |
I think the program you're suggesting is something like this, isn't it: script.File("t.txt").ExecForEach("md5sum $2; echo $1") Is that right? |
It works for me, although not very elegant script.File("/tmp/test/t.txt").ExecForEach(`bash -c "md5sum {{index .Cols 1}};echo {{index .Cols 0}}"`).Stdout()
// b42820e6479d5c5fa3a8e2daca66d1a1 /tmp/test/go.sum
// a
// 9659322eb77f7139a925f7745510c01e /tmp/test/go.mod
// b not works for this script.File("/tmp/test/t.txt").ExecForEach(`md5sum {{index .Cols 1}};echo {{index .Cols 0}}`).Stdout() |
Right, because using the |
Example
This is very flexible function in awk
In script, I except
The text was updated successfully, but these errors were encountered: