Skip to content
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

Q: 74/88 could have better input files #11

Open
FabijanC opened this issue Jun 5, 2024 · 0 comments
Open

Q: 74/88 could have better input files #11

FabijanC opened this issue Jun 5, 2024 · 0 comments

Comments

@FabijanC
Copy link

FabijanC commented Jun 5, 2024

It's also numerated as exercise 2) in https://learnbyexample.github.io/learn_gnuawk/multiple-file-input.html

For the input files sample.txt, secrets.txt, addr.txt and table.txt, display only the names of files that contain at or fun in the third field. Assume space as the field separator.

The expected solution is:

$ awk '$3 ~ /fun|at/{print FILENAME; nextfile}' sample.txt secrets.txt addr.txt table.txt

but it also works without nextfile.

Suggestion

Use a file which has multiple records containing at or fun in the third field, so that if you forget to use nextfile, the output is not matched due to a filename being printed more than once.

I would also add to the problem specification that the file name is expected to be printed once per file (if other criteria met).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant