We can't tell from your input data what your input file looks like. If it's tab-delimited, tell Awk to split on a tab:
awk -F '\t' '$5 != "./."' input.txt >output.txt
If you have a comma-delimited input file, the corresponding command would look like
awk -F ',' '$5 != "./."' input.txt >output.txt
The !=
string inequivalence operator is simpler to use than a regular expression here. We are simply saying "print lines where the fifth column is not exactly this string."
The corresponding regex would look like
awk -F ',' '$5 !~ /^\.\/\.$/' input.txt >output.txt
but you would obviously like to avoid the leaning toothpicks syndrome here.
In some more detail,
grep -v "./."
is wrong because it removes any line with a slash with any character at all on either side. You can fix this by escaping the dots with a backslash or character class; grep -v '\./[.]'
demonstrates both. This is still wrong in that it looks for the pattern anywhere, not just in the last field; but if you don't expect matches in other fields, maybe that's good enough.
awk '/"./."/'
looks for a slash surrounded by literal double quotes on both sides, with any character in between.
fgrep -xv "./."
is otherwise good, but the -x
option limits the expression to only match lines which contain nothing else than the pattern.
awk -F',' '$5 !~ "./." {print $0}'
would work for a comma-delimited file if you fix the regex. The { print $0 }
is redundant but harmless.
awk 'BEGIN { OFS=FS="\t" } $5 !~ /^('./.')/'
holds some promise for tab-delimited files, but the regex is hopelessly botched. The single quotes inside the regex are wrong, but will happily not break the syntax of the script; they will basically disappear before Awk processes the script because quotes are handled by the shell ... Long story short, read up on shell quoting.
awk '!"./." '
will not do anything; it says to print if the static string in the condition is empty, which it isn't.
sed -i '"./."d' input.txt > output.txt
is wrong because the -i
option will make changes to input.txt
and not print anything to standard output; the regex is flawed both because of the quoting problems and because it needs to be surrounded by valid regex delimiters. sed '/\.\/\./d' input.txt > output.txt
would work similarly to the first grep
example above.