Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

bash add or subtract one column from another

# Basic syntax:
awk 'BEGIN {set_delimiter}; {print $column# +_or_- $column#}' input_file

# Example usage:
awk 'BEGIN {OFS="	"}; {print $1 - $2}' input_file
# Set the delimiter to tab-delimited, print column 1 minus column 2

awk 'BEGIN {OFS="	"}; {print $0, $1 + $2}' input_file
# Set the delimiter to tab-delimited, print the original columns followed by
# column 1 plus column 2
Source by www.linuxquestions.org #
 
PREVIOUS NEXT
Tagged: #bash #add #subtract #column
ADD COMMENT
Topic
Name
8+8 =