[Solved] a variable list filtering via sed + "blacklist-variable" && Print,sed & userdbctl an other Solution. (all under CCSA/GPL2/3, Take your pick, able to add ITBS) #76
Answered
by
PsypherPunk
blackcrack
asked this question in
Q&A
|
dirlist=$(ls /home) => dirlist="blackcrack akira lost&found workshop garage office" the way to the result how become from the $dirlist i a filtering with the 3 words in the $blacklist i have try it via oneliner : but it works not really simply with sed.. mus i use there a loop or something over "while" best |
Answered by
PsypherPunk
Oct 3, 2022
Replies: 1 comment 1 reply
|
Presuming your variables are as above: dirlist="blackcrack akira lost&found workshop garage office"
blacklist="lost&found garage workshop"If you turn them into arrays then yes, you can exclude one from the other: dirlist_array=(${dirlist})
blacklist_array=(${blacklist})
for x in ${blacklist_array[@]}
do
dirlist_array=("${dirlist_array[@]/$x}")
doneThat will give you: $ echo ${dirlist_array[@]}
blackcrack akira officeIs that of any use? |
1 reply
Answer selected by
blackcrack
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Presuming your variables are as above:
If you turn them into arrays then yes, you can exclude one from the other:
That will give you:
Is that of any use?