subtract integer written in columns from 2 different files

This is an eg. of subtracting the integer value in column of file1 and file2.

root@tuxworld:/mnt# for i in `seq 1 5`;do echo $i >> file1;done
root@tuxworld:/mnt# for i in `seq 0 4`;do echo $i >> file2;done
root@tuxworld:/mnt# cat file1
1
2
3
4
5
root@tuxworld:/mnt# cat file2
0
1
2
3
4
root@tuxworld:/mnt# paste -d ‘ ‘ file1 file2|awk ‘{print $1 – $2}’
1
1
1
1
1
root@tuxworld:/mnt#

Read Some More Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.