[TangerineSDR] [HamSCI] Bash Scripting Help

Robert McGwier rwmcgwier at gmail.com
Sat Sep 10 11:50:04 EDT 2022


#!/bin/bash
dirs=($(find /tmp/test -type d))
for dir in "${dirs[@]}"; do
  cd "$dir"
  ls -pt | grep -v / | tail -n +4 | xargs rm -f
done
replace /tmp/test with your directory name.

On Tue, Sep 6, 2022 at 12:12 PM Jonathan <emuman100 at gmail.com> wrote:

> Hi All,
>
> 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:
>
> find locating the oldest files. There is often more than one and the
> naming convention is YYMMDD-HHMMSS. Running the following:
>
> find /data/vlf_32k -type f -mtime +50
>
> prints:
>
> /data/vlf_32k/220904-144416
> /data/vlf_32k/220904-150000
> ...
> /data/vlf_32k/220904-230000
>
> Next, we need to encode those files to flac to the archive directory:
>
> vtflac -e /data/vlf_32k/220904-144416 >
> /mnt/archive/vlf_32k_flac/220904-144416.fx
> vtflac -e /data/vlf_32k/220904-150000 >
> /mnt/archive/vlf_32k_flac/220904-150000.fx
> ...
> vtflac -e /data/vlf_32k/220904-230000 >
> /mnt/archive/vlf_32k_flac/220904-230000.fx
>
> Finally, delete the original files:
>
> rm /data/vlf_32k/220904-144416
> rm /data/vlf_32k/220904-150000
> ...
> rm /data/vlf_32k/220904-230000
>
> 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!
>
> Thank you!
>
> Jonathan
> KC3EEY
>
> --
> Please follow the HamSCI Community Participation Guidelines at
> http://hamsci.org/hamsci-community-participation-guidelines.
> ---
> You received this message because you are subscribed to the Google Groups
> "HamSCI" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to hamsci+unsubscribe at googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/hamsci/CAOY0kB3J3HX_8fFgNBgxzmCE2C3aVvPQO%3DNa54TiZX8RK23U-Q%40mail.gmail.com
> <https://groups.google.com/d/msgid/hamsci/CAOY0kB3J3HX_8fFgNBgxzmCE2C3aVvPQO%3DNa54TiZX8RK23U-Q%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Dr. Robert W McGwier, Ph.D.
Adjunct Faculty, Virginia Tech
Affiliated Faculty, University of Scranton
ARDC Member of Board
N4HY: ARRL, TAPR, AMSAT, EARC, CSVHFS
Sky: AAVSO, Sky360, Auburn A.S., Skyscrapers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.tapr.org/pipermail/tangerinesdr_lists.tapr.org/attachments/20220910/79c704bc/attachment.html>


More information about the TangerineSDR mailing list