Results 1 to 2 of 2

Thread: Understanding /dev/null

  1. #1

    Understanding /dev/null

    I am a beginner with Kali Linux and am learning with a textbook. I have written the following shell script:

    #! /bin/bash
    # This script is designed to find hosts with Postgres installed
    nmap -sT my_IP_address -p 5432 >/dev/null -oG MyPostgresScan
    cat MyPostgresScan | grep open > MyPostgresScan2
    cat MyPostgresScan2
    I try to understand what >/dev/null does. I assumed that the standard nmap output is sent to /dev/null and from what I have learned, this is a place in Linux where output disappears.

    When I run my shell script I can see that there are two files written to my pwd: MyPostgresScan and MyPostgresScan2. I expected MyPostgresScan not to be in my pwd. The second file is expected to be there.

    Can someone explain me why the file MyPostgresScan is written to my pwd?

  2. #2
    Join Date

    Ausgabe unterdr?cken

    You can use it to suppress the output in a shell.

    for example:

    echo "I am not displayed because I am suppressed!" > /dev/null

    This is often used when scripting to suppress an output that is not needed.

    Hope this helps you!

Similar Threads

  1. Replies: 1
    Last Post: 2020-06-24, 12:46
  2. Understanding the Pineapple Connector ?
    By BeNe in forum NetHunter General Questions
    Replies: 1
    Last Post: 2016-09-19, 18:44

Posting Permissions

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