Manually select/unselect lines before forwarding to stdout
Is there any way to grep interactively, meaning that I have a bunch of lines coming from somewhere that I want to pipe to further processing, with the option to manually specify the lines I want?
Consider this example:
#Name Food Music
Adam Cake Rock
Bert Fruit Folk
Caesar Cake Rock
Doris Cake Folk
Emil Fruit Rock
Francis Fruit Folk
Gertrud Cake Rock
...
I can take this file and filter it using lines like
cat people.txt | grep -v "^#" | grep "^.*Fruit.*Folk"
...to get all people to invite to a veggie Folk party. When I automate this further:
cat people.txt | grep -v "^#" | grep "^.*Fruit.*Folk" | ??? | peopleInviterScript
...I want to have some ???
in the pipe that gives me the option to select/unselect people before the invitations are sent.
Is there already such a tool in bash/zsh I just do not know about?
While I like the vipe
approach, I've found an even cooler way: fzf.
cat people.txt | grep -v "^#" | grep "^.*Fruit.*Folk" | fzf -m | cat
...gives a nice list where I can search in and toggle the items with the keyboard and disappears completely when I am done.
moreutils has vipe
, which just runs your regular text editor (vi or something) as part of the pipeline. Any lines that you don't delete will get written back to stdout. (In general, though, you get the same result by redirecting to a temporary file and editing that file.)