have file with 2 columns. trying to remove row when 2nd column is blank

Posted on 2005-04-06
Last Modified: 2013-12-27
have file that has many rows. 2 columns in each row, tab delimited. some rows have nothing in seconds column. i want to get rid of these rows!
Question by:pdadddino

    Author Comment

    figured it out
    awk '{if ($2 != "") print $0};' input file name  >  output file name
    LVL 20

    Accepted Solution

    If noone else has posted in your question, you should have an option to delete it yourself; But now you'll have to post in to ask them to delete it (Sorry!)

    By the way, if there were more than 2 columns in your file, you'd need to specify the field seperator - Otherwise awk just assumes any whitespace is a single field seperator

    awk -F "^I" '$2!="" {print $0}' input file name  >  output file name
    (where ^I is a <Tab> character, which can be inserted with Ctrl-V then Ctrl-I

    Alternatively, in this example, you could just go on the number of fields:
    awk 'NF==2 {print $0}' input file name  >  output file name

    Author Comment

    did not want to delete just for others possible edification!
    Thanks for the additional solutions!

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
    Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
    Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
    Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now