1

If the input look like this:

    1
    2 4 5 6 7 19
    20
    22
    24 26 27 
    29 30 31 32 34 40 50 56 58
    234 235 270 500
    1234 1235 1236 1237
    2300

I want to delete the rows with less than 2 columns, so the output should look like:

    2 4 5 6 7 19
    24 26 27 
    29 30 31 32 34 40 50 56 58
    234 235 270 500
    1234 1235 1236 1237
5

As steeldriver commented:

awk 'NF>1' input > output

Another way:

grep '[^ ] [^ ]' input > output

(look for a non-space character followed by a space, followed by a non-space character).

To edit it "in-place":

sed -i '/[^ ] [^ ]/!d' input

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.