Skip to main content
added 2 characters in body
Source Link
jimmij
  • 48.7k
  • 20
  • 136
  • 141

Just store the value of date +%Y%m%d%H%M%S in a variable:

x=$(date +%Y%m%d%H%M%S)

and later on

mv file1 file1_$x.txt
mv file2 file2_$x.txt
...

or in a loop for all *.txt files

for file in *.txt; do echo mv "$file" "${file%.txt}"_$x.txt; done

(remove echo if you are happy with what you see on the screen)

Just store the value of date +%Y%m%d%H%M%S in a variable:

x=$(date +%Y%m%d%H%M%S)

and later on

mv file1 file1_$x.txt
mv file2 file2_$x.txt
...

or in loop for all *.txt files

for file in *.txt; do echo mv "$file" "${file%.txt}"_$x.txt; done

(remove echo if you are happy with what you see on the screen)

Just store the value of date +%Y%m%d%H%M%S in a variable:

x=$(date +%Y%m%d%H%M%S)

and later on

mv file1 file1_$x.txt
mv file2 file2_$x.txt
...

or in a loop for all *.txt files

for file in *.txt; do echo mv "$file" "${file%.txt}"_$x.txt; done

(remove echo if you are happy with what you see on the screen)

Source Link
jimmij
  • 48.7k
  • 20
  • 136
  • 141

Just store the value of date +%Y%m%d%H%M%S in a variable:

x=$(date +%Y%m%d%H%M%S)

and later on

mv file1 file1_$x.txt
mv file2 file2_$x.txt
...

or in loop for all *.txt files

for file in *.txt; do echo mv "$file" "${file%.txt}"_$x.txt; done

(remove echo if you are happy with what you see on the screen)