Artificial intelligent assistant

Replace values per sign (+/-) in a column I am trying to build a .bed file with genome coordinates and I am pretty close. Just missing the final step. I have a file that looks like this: LQNS02278165.1 13104710 13109495 BEL-1_PH-I 4785 LQNS02278165.1 9139127 9142308 BEL-1_PH-I 3181 LQNS02278165.1 9222957 9221339 BEL-1_PH-I -1618 I need to replace the 5 column with the sign, with is gonna be the orientation in the genome. ideally the output looks like this: LQNS02278165.1 13104710 13109495 BEL-1_PH-I + LQNS02278165.1 9139127 9142308 BEL-1_PH-I + LQNS02278165.1 9222957 9221339 BEL-1_PH-I - Any suggestion with awk will be very appreciated! Thanks

This should be enough:


awk '{$NF=($NF<0 ? "-" : "+")}1' file


* `$NF=($NF<0 ? "-" : "+")` If last field is negative, replace it with a minus sign, else replace it with a plus sign.

* `1` prints the line.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 8929069e2189329561a6d151ae8ad763