Skip to content

Instantly share code, notes, and snippets.

@frayos
Created January 22, 2018 16:17
Show Gist options
  • Select an option

  • Save frayos/3fb7fab3a25c0931c10daab492bf66d5 to your computer and use it in GitHub Desktop.

Select an option

Save frayos/3fb7fab3a25c0931c10daab492bf66d5 to your computer and use it in GitHub Desktop.
Change Date Modification time for SDW logs in case of wrong transfer
#!/bin/bash
##################################################
##################################################
#FOR SAS DEPLOYMENT WIZARD LOGS #################
##################################################
##################################################
##################################################
NEWIDR=NEW/
mkdir $NEWDIR
for i in `ls SDW_sysinfo_*`
do
#SDW_sysinfo_20151006_122839.dat
filename=$(basename "$i")
extension="${filename##*.}"
filename="${filename%.*}"
dateyyyymmdd=`echo $filename |cut -d_ -f3`
timehhmmss=`echo $filename |cut -d_ -f4`
timehhmm="${timehhmmss%??}"
timess="${timehhmmss: -2}"
timestamptouch="$dateyyyymmdd$timehhmm.$timess"
touch -m -t "$timestamptouch" $i
mv $i $NEWDIR
echo $i
done;
exit
for i in `ls | grep -v SDW_sysinfo_`
do
filename=$(basename "$i")
extension="${filename##*.}"
filename="${filename%.*}"
datetocut=`echo "$filename" | cut -d_ -f2`
dateyyyy=`echo "$datetocut" | cut -d- -f1`
datemm=`echo "$datetocut" | cut -d- -f2`
datedd=`echo "$datetocut" | cut -d- -f3`
timehhmmss=`echo "$datetocut" | cut -d- -f4`
timehh=`echo "$timehhmmss" | cut -d. -f1`
timemm=`echo "$timehhmmss" | cut -d. -f2`
timess=`echo "$timehhmmss" | cut -d. -f3`
timestamptouch="$dateyyyy$datemm$datedd$timehh$timemm.$timess"
echo $timestamptouch
touch -m -t "$timestamptouch" $i
mv $i $NEWDIR
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment