What I am trying to do is kind of hard to explain. Let's say I have a directory with a bunch of different users submitting stuff into it. I ask for a file with the extension ".foo" from everyone. Then I asked for a file with the extension ".bar" from everyone. I want a list of names of everyone who submitted .foo, but did not submit .bar.
I'm assuming you somehow use grep twice and include the owner name inside the grep, but that's kind of where I get confused. I am trying to do this all in one command pipeline.
This is what I'm trying to do to retrieve the names:
find . -type f -printf "%u %f\n" | grep '%u .foo' | grep -v '%u .bar'
My two problems here are that %u
doesn't give the name from the printf
and that the excluding bar part isn't dependent off of grep foo. It's meant to list the names of all of the people that own foo, then remove the names of the people who have submitted bar.
Structure as per request:
|--myDirectory
├── samantha.foo - (owner: samantha warren)
├── samantha.bar - (owner: samantha warren
├── robert.foo - (owner: robert jones)
├── doug.foo - (owner: doug field)
├── doug.bar - (owner: doug field)
├── emily.foo - (owner: emily smith)
The output should be as follows:
robert jones
emily smith