unix - Extract multiple strings per line separated by special character from a file -


i file (filemanes.txt) containing file names in text file. each line contain 1 or more file names separated #.

#filename1# #filename2#filename3#filename4# #filename5#filename6# .... 

in loop browse directory content, need compare each file name found in directory each filenamex found filemanes.txt

i guess can sed and/or awk miss skills

if can great

thank's

comparing each file each name slow. let tools of work:

for file in * ;     grep -o "#$file#" filenames.txt done 

or, without loop:

ls | sed 's/^\|$/#/g'| grep -off- filenames.txt 

note if filenames contained spaces , other special characters, solutions more complicated.


Comments