Translating Filenames — Bash Voodoo Style #linux

This is an example of using Bash to convert a crazy apache log and translating the filename into an IIS log pattern:

d=`date +%Y%m%d`
find k -type f \
| while read filename
do
  nextfile="${filename/k\/done?0.www\./k2/www-Server_T${d}_}.log"
  echo "$nextfile"
  cat $filename | $translate > "$nextfile"
done

I love how I can refer to a shell variable ($d) inside a string translation (${d}).

Advertisements

Tail the Latest Log File

I’m grateful for Cygwin. I wouldn’t know how to do this in cmd–though I should probably learn how to do it in PoSH.

find LogFiles/W3SVC1 -type f | xargs ls -1tr | tail -n1 | xargs tail -F

I need to make it an alias now….