#!/bin/bash
ARCHIVE_PATH=/archive
CURRENT_DATE='date +%F%H%M%S'
echo running at `date` >>~/Logs.txt
for FolderToSearch in $(ls -l /home/stuff/tp |grep ^d|awk '{print $9}');
do find /home/stuff/tp/$FolderToSearch/in -name '*.*'|awk '{print "zip -m " $ARCHIVE_PATH "_" $FolderToSearch "zip2arc.zip" $CURRENT_DATE;}'|bash|tee -a ~/Logs.txt;
done
Hi there,
I'd appreciate it if anyone can tell me how to use variables within the print statement of an awk statement. The above code is meant to
1. List a directory.
2. For each subdirectory, list the files in its in/ folder.
3. Zip these files into a /archive/zip file (also removing them zip -m)
Ideally, the zip file would have the name of the folder it came from as a prefix of its filename and the date as postfix.
The problem is that $CURRENT_DATE and $ARCHIVE_PATH are not expanded to their values. I've tried using single quotes etc.Note that this is on AIX, where find and awk, although very similar, are a little bit primitive compared to their GNU counterparts.
If anyone can recommend a good hair transplant clinic too I'd be eternally in your debt.
Thanks in advance.