You are not logged in.
I have config file for small script and it looks like this:
local_directory="$HOME/etc"
excluded_directory="$HOME/etc1"
excluded_directory2="$HOME/etc2"
excluded_directory3="$HOME/etc3"
I would like to place all "excluded_directoryXX" config options into array that can be parsed to program. This way i have to hardcode it and it is not practical at all.
Can somebody help me out?
Last edited by kuraku (2013-09-24 20:45:42)
Offline
mapfile -t configs </etc; echo "${configs[@]}"
Offline
@jasonwryan
Thank you, i was not aware of that builtin. At first i wanted to use this in combination with "grep --after-context=XX" and then i realized that i can use it this way:
mapfile -s XX -t configs </etc; echo "${configs[@]}"
Thank you very much.
Offline
Glad you got what you needed. I wasn't sure what sort of output you were looking for, it helps if you include that to remove ambiguity and/or uncertainty.
Please remember to mark your thread as [Solved] by editing your first post and prepending it to the title.
Offline
o_0
I am completely failing to understand what " </etc" is supposed to achieve. Is it shorthand for " </etc/somefile" or ... ?
But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner
Offline
o_0
I am completely failing to understand what " </etc" is supposed to achieve. Is it shorthand for " </etc/somefile" or ... ?
Yes, it is reading stdin and in this case, it is somefile.
Offline