Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

bash swap two columns in a file

# Example usage:
awk '{t=$1; $1=$2; $2=t; print;}' input_file # Swap column 1 and column 2
# Where:
#	- this assigns column 1 to a dummy variable t, makes column 1 equal
# 		to column 2, and then assigns the contents of t to column 2
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #bash #swap #columns #file
ADD COMMENT
Topic
Name
3+1 =