Most efficient way to to search for lines with a substring match in bash? -


i have list of names noise , list of clean names, sure clean names exact substring of names noise.

lets have name noise, example var?goldenfoo, , output, text file cleannames looks this

golden blue red 

golden.

i have tried using grep cated cleannames, seems rather unneficient.

try:

grep -fof cleannames.txt text.txt 

if want else, edit question , add more details. :)

let have this:

impedit quas et totam in omnis. voluptas repellat voluptas possimus rerum est goldennihil. et ut minima sit. quia accusamus rerum voluptate. dolores molestiae non dolorem dignissimos quaerat magni. quia reiciendis cupigoldenditate quo hic doloremque molestiae. odio odio quis est quisquam eligendi esse. quo natus architecto in id dolorum eveniet. modi error dolorum voluptas ulredlam aut. soluta veniam corporis est. illum maximegolden perferendis incidunt qui consequatur. laborum quia ab voluptatem.

will print

golden golden red golden 

and the

echo 'var?goldenfoo' | grep -fof cleannames.txt 

will print

golden 

or

clean=(golden red blue)  #or read array file... text='var?goldenfoo'  grep -fof <(printf "%s\n" "${clean[@]}") <<< "$text" 

prints

golden 

so can instead of cleannames.txt have process substitution , instead of text.txt can have redirection. combination work.


Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -