I am using the following code to read specific lines in an ASCII file text.datsed -n '/Columnaxis/p' text.datThe output is Columnaxis: 100In order to output only the second part previous line, I added the following to the previous command line: sed -n '/Columnaxis/p' text.dat | awk '{ print $2 }'The output of the last command is 100How can I update the last code to output negative numbers, regardless of the number's original sign? ( i.e if the input is +100 I want the code to output -100 also if the input is -100, I want the code to output -100PS. The content of text.dat is something like the following :Columnaxis: 100Columnaxis_1: 100Columnaxis_2: -100Columnaxis_3: 50Columnaxis_4: -2.3Columnaxis_5: 1.2Columnaxis_6: -5Columnaxis_7: -2Columnaxis_8: -4Columnaxis_9: -2I want the code to output the following:Columnaxis: -100Let's say that the input has Columnaxis: +100, then I want it to beColumnaxis: -100
Output negative values, regardless of original sign, on selected lines
text processing
Or awk alone:$ cat text.datColumnaxis: 100Columnaxis: +100Columnaxis: -100$ awk '/Columnaxis/ { gsub(-|+, , $2); print -$2 }' text.dat-100-100-100