Results 1 to 2 of 2

Thread: Print only one line of a file / output.

  1. #1
    Join Date
    Aug 2006
    Beans
    24

    Print only one line of a file / output.

    I need to do what the title states.

    For example, entering

    Code:
    nmap -sP 192.168.1.0/24 | grep 'Nmap scan report'
    returns

    Code:
    Nmap scan report for 192.168.1.1
    Nmap scan report for 192.168.1.8
    Nmap scan report for 192.168.1.4
    How can I get it to only output say...line 2? I assume some sort of awk line?

  2. #2
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,499
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Print only one line of a file / output.

    Code:
    ... | awk 'NR==2'
    or
    Code:
    ... | sed -n 2p
    if your question is answered, mark the thread as [SOLVED]. Thx.
    To post code or command output, use [code] tags.
    Check your bash script here // BashFAQ // BashPitfalls

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
  •