My bad I did not read it your request correctly. Any ways here is the solution
Code:
ls -l --time-style="+%b %e, %Y %k%M" log.txt | awk '{ print $6"-"$7"-"$8 }' | sed -e 's/,//g'
And here is what you need to do at a shell prompt:
Code:
NOW=$(ls -l --time-style="+%b %e, %Y %k%M" log.txt | awk '{ print $6"-"$7"-"$8 }' | sed -e 's/,//g')
cp log.txt $NOW.log.txt
ls *.txt
Or better put in script (vi script.sh) :
Code:
#!/bin/bash
FILE=$1
NOW=$(ls -l --time-style="+%b %e, %Y %k%M" $FILE | awk '{ print $6"-"$7"-"$8 }' | sed -e 's/,//g')
cp $FILE "$NOW.$FILE"
echo "File $FILE == $NOW.$FILE"
Run script as follows:
Code:
chmod +x script.sh
./script.sh file.txt
./script.sh log.txt
Enjoy!