View Single Post

  #4 (permalink)  
Old 03-29-2006, 04:51 PM
nixcraft's Avatar
nixcraft nixcraft is offline
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Ubuntu
Posts: 1,101
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

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!
__________________
Vivek | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote