Results 1 to 8 of 8

Thread: What does "grep "something" > /dev/null" do?

Threaded View

  1. #1
    Join Date
    Dec 2007
    Location
    Bombay
    Beans
    5,752
    Distro
    Lubuntu 14.04 Trusty Tahr

    What does "grep "something" > /dev/null" do?

    Stinkeye posted a code using wmctrl to detect whether a window is present (minimized or not). If it is present, it is brought into focus. If the window doesn't exist, the application is run:
    Code:
    sh -c "wmctrl -a <str> || <start command>"
    I came across a lengthier version here, and in the context of using wmctrl, it would look something like this:
    Code:
    #!/usr/bin/env bash
    
    if wmctrl -l | grep -i "Firefox" > /dev/null
    then
      wmctrl -a firefox
    else
      firefox
    fi
    My question is about "grep -i "Firefox" > /dev/null": how does that work? What does "> /dev/null" do?

    A second point is that the author used "[f]irefox" instead of just "firefox" but I couldn't understand the reason for that.
    Last edited by vasa1; October 13th, 2013 at 08:04 AM.
    de gustibus et coloribus non est disputandum -- Wiktionary

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •