Bash scripting 3 – array
I have now figured out how to take a directory listing and put the contents in to an array. I had some help from a Stack Overflow post
#take a directory listing and store files in an array
#! /bin/bash
var=(*)
printf '[%q]\n' "${var[@]}" # store all files in directory in array var
echo $var[png];
You will, of course, need to set execute permissions
chmod +x script.sh
Tags
#Bash,#BashScripting,#BatchProcessing
Mastodon | Peertube | Join Mastodon |
AI statement : Consent is NOT granted to use the content of this blog for the purposes of AI training or similar activity. Consent CANNOT be assumed, it has to be granted.