<div dir="ltr">#!/bin/bash<br>dirs=($(find /tmp/test -type d))<br>for dir in "${dirs[@]}"; do<br> cd "$dir"<br> ls -pt | grep -v / | tail -n +4 | xargs rm -f<br>done<br>replace /tmp/test with your directory name.<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Sep 6, 2022 at 12:12 PM Jonathan <<a href="mailto:emuman100@gmail.com">emuman100@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi All,<br><div><br></div><div>I need some assistance in writing a bash script that will run as a cron job to archive VLF data. The data is recorded in hour-long chunks as files. I have a cleardown script that will cleardown the oldest files and always maintain a rotating buffer, so as the newest file is being recorded, the oldest file is being deleted. What I need now is a way to locate the oldest file, encode it to flac using vlfrx-tools vtflac utility, then delete the original file. Here is an example:</div><div><br></div><div>find locating the oldest files. There is often more than one and the naming convention is YYMMDD-HHMMSS. Running the following:</div><div><br></div><div>find /data/vlf_32k -type f -mtime +50<br> </div><div>prints:</div><div><br></div><div>/data/vlf_32k/220904-144416<br></div><div>/data/vlf_32k/220904-150000</div><div>...</div><div>/data/vlf_32k/220904-230000<br></div><div><br></div><div>Next, we need to encode those files to flac to the archive directory:</div><div><br></div><div>vtflac -e /data/vlf_32k/220904-144416 > /mnt/archive/vlf_32k_flac/220904-144416.fx</div><div>vtflac -e /data/vlf_32k/220904-150000 > /mnt/archive/vlf_32k_flac/220904-150000.fx<br></div><div>...</div><div>vtflac -e /data/vlf_32k/220904-230000 > /mnt/archive/vlf_32k_flac/220904-230000.fx<br></div><div><br></div><div>Finally, delete the original files:</div><div><br></div><div>rm /data/vlf_32k/220904-144416</div><div>rm /data/vlf_32k/220904-150000</div><div>...</div><div>rm /data/vlf_32k/220904-230000<br></div><div><br></div><div>I haven't done a lot of bash scripting, so I'm asking if anyone here may have experience with this. I need the above commands to be executed by a bash script so it'll complete those commands no matter how many files that the find utility will find. Sometimes, there will be no files the find utility locates and the script should just exit. It'll be executed every hour by cron. Any help or assistance will be appreciated!</div><div><br></div><div>Thank you!</div><div><br></div><div>Jonathan</div><div>KC3EEY </div></div>
<p></p>
-- <br>
Please follow the HamSCI Community Participation Guidelines at <a href="http://hamsci.org/hamsci-community-participation-guidelines" target="_blank">http://hamsci.org/hamsci-community-participation-guidelines</a>.<br>
--- <br>
You received this message because you are subscribed to the Google Groups "HamSCI" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="mailto:hamsci+unsubscribe@googlegroups.com" target="_blank">hamsci+unsubscribe@googlegroups.com</a>.<br>
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/hamsci/CAOY0kB3J3HX_8fFgNBgxzmCE2C3aVvPQO%3DNa54TiZX8RK23U-Q%40mail.gmail.com?utm_medium=email&utm_source=footer" target="_blank">https://groups.google.com/d/msgid/hamsci/CAOY0kB3J3HX_8fFgNBgxzmCE2C3aVvPQO%3DNa54TiZX8RK23U-Q%40mail.gmail.com</a>.<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr" style="font-size:small"><span style="color:rgb(80,0,80)">Dr. Robert W McGwier, Ph.D.</span><br style="color:rgb(80,0,80)"><span style="color:rgb(80,0,80)">Adjunct Faculty, Virginia Tech</span></div><div dir="ltr" style="font-size:small">Affiliated Faculty, University of Scranton<br style="color:rgb(80,0,80)"><span style="color:rgb(80,0,80)">ARDC Member of Board</span><br style="color:rgb(80,0,80)"><span style="color:rgb(80,0,80)">N4HY: ARRL, TAPR, AMSAT, EARC, CSVHFS</span><br style="color:rgb(80,0,80)"><span style="color:rgb(80,0,80)">Sky: AAVSO, Sky360, Auburn A.S., Skyscrapers</span><br></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>