linuxbashcommand-linegrepack

Finding a string within a file and outputting results


I would like grab one line (1 term) at a time from file1.txt and search sFile.txt... outputting all the lines that have the found term in it. file1.txt (300 lines) sFile.txt (100k lines). I would like to use a command line (linux) fgrep, ack, find, etc. I have tried a fgrep command but I am hitting the character limit so nothing is being processed.

tried: fgrep -wi 'front1' test.log >> final.txt this worked but when adding file1.txt the process was not able to run

file1.txt structure (case insensitive)

front1
front2
FrOnT3

sFile.txt structure

106.4 - - [12/Aug/2020:10:46:57 -0400] "GET /skin/front1/sharp_bootstrap/default/css"
106.4 - - [12/Aug/2020:10:46:57 -0400] "GET /skin/front3/sharp_bootstrap/default/css"
106.4 - - [12/Aug/2020:10:46:57 -0400] "GET /skin/front2/sharp_bootstrap/default/css"
106.4 - - [12/Aug/2020:10:46:57 -0400] "GET /skin/front0/sharp_bootstrap/default/css"

final.txt three lines should have been found

106.4 - - [12/Aug/2020:10:46:57 -0400] "GET /skin/front1/sharp_bootstrap/default/css"
106.4 - - [12/Aug/2020:10:46:57 -0400] "GET /skin/front3/sharp_bootstrap/default/css"
106.4 - - [12/Aug/2020:10:46:57 -0400] "GET /skin/front2/sharp_bootstrap/default/css"

Solution

  • I found the solution... Source for Solution

    fgrep -v -F -f file1.txt sFile.txt