-2

My input file contains some series of commands for a number for eg.

13287
13288
13289

I want the following output in all the file.

13281
13282
13283

I am using the following command saved in a script file as I pass the first four digits as argument in the script file.

#!/bin/bash
cat $1_final.txt | tr "$17" "$11" > $1.tmp

Instead of the desired output I am getting the following output. I have checked again the argument passed it 1328 else it will not be able to get the file because the file in the directory is 1328_final.txt

13221

Where I am doing this wrong?

Mohit Kumar
  • 46
  • 1
  • 2
  • 11

1 Answers1

1

the first argument to tr is a set of characters which will be globally replaced by the corresponding letter from the 2nd arg, another set of characters.

To subtract 6 from each line can be accomplished in many ways:

while read num; do echo $((num-6)); done < file
awk '{print $1 - 6}' file
sed 's/$/ - 6/' file | bc
sed 's/$/ 6 - p/' file | dc
glenn jackman
  • 238,783
  • 38
  • 220
  • 352