Skip to main content
3 of 4
added 11 characters in body
terdon
  • 252.3k
  • 69
  • 480
  • 718

How to change integer in bash script according to written .dat filenames

In my bash script, I want to update a string according to new written filenames with .dat format. Here is what I am trying to do:

  • For example, I use a file named blabla_3200.dat in my bash script, then run a case with this script.
  • After this case is done, a new blabla_3300.dat is written in the same directory
  • For the next run, I want to use this last blabla_3300.dat in the same bash script.

Therefore, I have to search for the largest integer in the file names .dat, and then use sed to update my bash script like:

sed -i 's/3200/max/g' mybash.sh

then run a new case.

Any help will be appreciated Have a good day!

hll
  • 1
  • 1