so im trying to get this command to work under macOS Sierra and I'm not having too much luck. basically what I want to do is have terminal echo every line, except ones containing a certain pattern of text, and finally save it to a text document. the command I am trying is:

shasum -c /Users/NAME/Desktop/foo.txt | grep -v ': OK' > /Users/NAME/Desktop/bar.txt

I don't want terminal to output & save lines that contain : OK in them. No lines are saved to bar.txt at all.

My output I get from running shasum -c /Users/NAME/Desktop/foo.txt is

/Volumes/HDD-1/myfile.txt: OK
/Volumes/HDD-1/badhash.psd: FAILED
/Volumes/HDD-1/steak.png: OK
/Volumes/HDD-1/bliss.flac: OK
/Volumes/HDD-1/missingfile.rar: FAILED open or read
/Volumes/HDD-1/timer.dmg: OK

EDIT: It's also probably good to note that when I run the first command, I see the correct text outputted to the terminal window, but it's never outputted to the bar.txt.

EDIT 2: I originally got this idea from this video at 0:54. If you look closely, you can see a similar command being run in the left side of the screen. It seems to work fine for this guy, but he's not outputting to a file.

closed as unclear what you're asking by RomanPerekhrest, Michael Homer, Kusalananda, user34720, GAD3R Jun 27 '17 at 11:12

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    What does shasum -c /Users/NAME/Desktop/foo.txt output? – Michael Homer Jun 27 '17 at 7:32
  • can not reproduce: works fine outputting /Volumes/HDD-1/badhash.psd: FAILED /Volumes/HDD-1/missingfile.rar: FAILED open or read – RomanPerekhrest Jun 27 '17 at 8:05
  • Really? I get an empty file every time. – Terkey-Juice Jun 27 '17 at 8:06
  • 1
    ("We" is you in this instance) – Michael Homer Jun 27 '17 at 8:22
  • 1
    That command obviously should result in a blank file, so it's not a terribly useful command to try. – Michael Homer Jun 27 '17 at 8:31

Browse other questions tagged or ask your own question.