Script to append timestamp prefix to variable

88 Views Asked by At

I've got a Thunar script with this only line: cp "$@" "$@-$TS".txt it appends a timestamp suffix and the .txt extension to the file I right-click in

Now, I want to append a timestamp prefix and also add the .txt extension, but it doesn't work: cp "$@" "$TS-$@".txt

What am I doing wrong?

1

There are 1 best solutions below

0
oak-island-pirate On BEST ANSWER

Well, I've found a solution. Replace geany with your favourite text editor.

#!/bin/sh
TS=$( date +%Y%m%d-%H%M%S )
cp "$@" $TS.txt
geany $TS.txt