Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • 1
    Lose the [] and it'll work. Though you probably want to quote your pattern: if grep -q "^$1" schemas.txt; then … Commented Sep 18, 2012 at 19:25
  • 1
    one line solution using Bash's "Group Command" feature: stackoverflow.com/questions/6550484/… Commented Sep 27, 2016 at 19:46
  • 1
    Bash oneliner. If the string "foo" is found in file content.txt then run the command work.sh, otherwise do nothing : cat content.txt | grep "foo" && work.sh Commented Nov 18, 2020 at 16:07