I have a file that looks like this:     1 abcde     2 00     3 12     4 12     5 ghijkl     6 jsaslm     7 uawrns     8 abcde     9 \(%!&/    10 $!$&/(    90 !%/(//I want to replace all numbers greater than 3 in the first column (meaning the one that contains 1, 2 etc.). They should be replaced by the result of the calculation of the number modulo 3 - except for the numbers which are divisable by 3 (those should just be 3).So the result should look like this:     1 abcde     2 00     3 12     1 12     2 ghijkl     3 jsaslm     1 uawrns     2 abcde     3 \(%!&/     1 $!$&/(     3 !%/(//Formatting doesnt matter much, but the way shown above would be preferred.I'm using Linux. 
Replace numbers in first section of file by result of calculation
text processing
With awk for your updated questionawk '$1{$1=$1%3?$1%3:3}1' file 1 abcde 2 00 3 12 1 12 2 ghijkl 3 jsaslm 1 uawrns 2 abcde 3 \(%!&/ 1 $!$&/( 3 !%/(//