Skip to main content
added 174 characters in body
Source Link
chaos
  • 49.4k
  • 11
  • 128
  • 147

With awk:

awk -F"\t" '$1!=""&&$2!=""&&$3!=""' file

Actually it is that simple.

  • awk splits the input at the field separator tab \t specified with the -F flag. This could also be omitted, when your content has no spaces in the fields.
  • $1!=""&&... is a condition. When this condition is true, awk simply prints the line. You could also write '$1!=""&&$2!=""&&$3!=""{print}', but that's not necessary. Awks default behavior is to print the line, when no action is given. Here, that condition is true when the fields $1, $2 and $3 all are not empty, hence when the first 3 fields have a value.

To write to another file use this:

awk -F"\t" '$1!=""&&$2!=""&&$3!=""' input_file >output_file

Edit: With an undefined number of columns you could use this awk, it check every field in the line:

awk -F"\t" '{for(i=1;i<=NF;i++){if($i==""){next}}}1' file

With awk:

awk -F"\t" '$1!=""&&$2!=""&&$3!=""' file

Actually it is that simple.

  • awk splits the input at the field separator tab \t specified with the -F flag. This could also be omitted, when your content has no spaces in the fields.
  • $1!=""&&... is a condition. When this condition is true, awk simply prints the line. You could also write '$1!=""&&$2!=""&&$3!=""{print}', but that's not necessary. Awks default behavior is to print the line, when no action is given. Here, that condition is true when the fields $1, $2 and $3 all are not empty, hence when the first 3 fields have a value.

To write to another file use this:

awk -F"\t" '$1!=""&&$2!=""&&$3!=""' input_file >output_file

With awk:

awk -F"\t" '$1!=""&&$2!=""&&$3!=""' file

Actually it is that simple.

  • awk splits the input at the field separator tab \t specified with the -F flag. This could also be omitted, when your content has no spaces in the fields.
  • $1!=""&&... is a condition. When this condition is true, awk simply prints the line. You could also write '$1!=""&&$2!=""&&$3!=""{print}', but that's not necessary. Awks default behavior is to print the line, when no action is given. Here, that condition is true when the fields $1, $2 and $3 all are not empty, hence when the first 3 fields have a value.

To write to another file use this:

awk -F"\t" '$1!=""&&$2!=""&&$3!=""' input_file >output_file

Edit: With an undefined number of columns you could use this awk, it check every field in the line:

awk -F"\t" '{for(i=1;i<=NF;i++){if($i==""){next}}}1' file
added 8 characters in body
Source Link
Stéphane Chazelas
  • 586.4k
  • 96
  • 1.1k
  • 1.7k

With awk:

awk -F"\t" '$1!=""&&$2!=""&&$3!=""' file

Actually it is that simple.

  • awk splits the input at the field separator tab \t specified with the -F flag. This could also be omitted, when your content has no spaces in the fields.
  • $1!=""&&... is a condition. When this condition is true, awk simply prints the line. You could also write '$1&&$2&&$3'$1!=""&&$2!=""&&$3!=""{print}', but that's not necessary. Awks default behavior is to print the line, when no commandaction is given. HoweverHere, that condition is true, when the fields $1, $2 and $3 all are not empty, hence when there arethe first 3 fields with valueshave a value.

To write to another file use this:

awk -F"\t" '$1!=""&&$2!=""&&$3!=""' input_file >output_file

With awk:

awk -F"\t" '$1!=""&&$2!=""&&$3!=""' file

Actually it is that simple.

  • awk splits the input at the field separator tab \t specified with the -F flag. This could also be omitted, when your content has no spaces in the fields.
  • $1!=""&&... is a condition. When this condition is true, awk simply prints the line. You could also write '$1&&$2&&$3{print}', but that's not necessary. Awks default behavior is to print the line, when no command is given. However, that condition is true, when the fields $1, $2 and $3 all are not empty, hence when there are 3 fields with values.

To write to another file use this:

awk -F"\t" '$1!=""&&$2!=""&&$3!=""' input_file >output_file

With awk:

awk -F"\t" '$1!=""&&$2!=""&&$3!=""' file

Actually it is that simple.

  • awk splits the input at the field separator tab \t specified with the -F flag. This could also be omitted, when your content has no spaces in the fields.
  • $1!=""&&... is a condition. When this condition is true, awk simply prints the line. You could also write '$1!=""&&$2!=""&&$3!=""{print}', but that's not necessary. Awks default behavior is to print the line, when no action is given. Here, that condition is true when the fields $1, $2 and $3 all are not empty, hence when the first 3 fields have a value.

To write to another file use this:

awk -F"\t" '$1!=""&&$2!=""&&$3!=""' input_file >output_file
added 31 characters in body
Source Link
chaos
  • 49.4k
  • 11
  • 128
  • 147

With awk:

awk -F"\t" '$1&&$2&&$3''$1!=""&&$2!=""&&$3!=""' file

Actually it is that simple.

  • awk splits the input at the field separator tab \t specified with the -F flag. This could also be omitted, when your content has no spaces in the fields.
  • $1&&$2&&$3$1!=""&&... is a condition. When this condition is true, awk simply prints the line. You could also write '$1&&$2&&$3{print}', but that's not necessary. Awks default behavior is to print the line, when no command is given. However, that condition is true, when the fields $1, $2 and $3 all are setnot empty, hence when there are 3 fields with values.

To write to another file use this:

awk -F"\t" '$1&&$2&&$3''$1!=""&&$2!=""&&$3!=""' input_file >output_file

With awk:

awk -F"\t" '$1&&$2&&$3' file

Actually it is that simple.

  • awk splits the input at the field separator tab \t specified with the -F flag. This could also be omitted, when your content has no spaces in the fields.
  • $1&&$2&&$3 is a condition. When this condition is true, awk simply prints the line. You could also write '$1&&$2&&$3{print}', but that's not necessary. Awks default behavior is to print the line, when no command is given. However, that condition is true, when the fields $1, $2 and $3 all are set, hence when there are 3 fields with values.

To write to another file use this:

awk -F"\t" '$1&&$2&&$3' input_file >output_file

With awk:

awk -F"\t" '$1!=""&&$2!=""&&$3!=""' file

Actually it is that simple.

  • awk splits the input at the field separator tab \t specified with the -F flag. This could also be omitted, when your content has no spaces in the fields.
  • $1!=""&&... is a condition. When this condition is true, awk simply prints the line. You could also write '$1&&$2&&$3{print}', but that's not necessary. Awks default behavior is to print the line, when no command is given. However, that condition is true, when the fields $1, $2 and $3 all are not empty, hence when there are 3 fields with values.

To write to another file use this:

awk -F"\t" '$1!=""&&$2!=""&&$3!=""' input_file >output_file
added 22 characters in body
Source Link
chaos
  • 49.4k
  • 11
  • 128
  • 147
Loading
typo
Source Link
chaos
  • 49.4k
  • 11
  • 128
  • 147
Loading
Source Link
chaos
  • 49.4k
  • 11
  • 128
  • 147
Loading