Timeline for grep command in bash shell loop [duplicate]
Current License: CC BY-SA 4.0
16 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Aug 20, 2019 at 9:32 | history | duplicates list edited | Kusalananda♦ | duplicates list edited from How do I grep lines ending on a specific expression to grep -f failing on a file edited in Windows, How do I grep lines ending on a specific expression, Grep a string in a file in bash [duplicate] | |
| Aug 20, 2019 at 9:32 | history | closed | Kusalananda♦ linux Users with the linux badge or a synonym can single-handedly close linux questions as duplicates and reopen them as needed. | Duplicate of How do I grep lines ending on a specific expression | |
| Aug 20, 2019 at 9:02 | vote | accept | Dwija | ||
| Aug 20, 2019 at 9:01 | vote | accept | Dwija | ||
| Aug 20, 2019 at 9:01 | |||||
| Aug 20, 2019 at 9:00 | vote | accept | Dwija | ||
| Aug 20, 2019 at 9:01 | |||||
| Aug 20, 2019 at 9:00 | answer | added | Dwija | timeline score: 0 | |
| Aug 19, 2019 at 14:11 | answer | added | glenn jackman | timeline score: 3 | |
| Aug 19, 2019 at 8:06 | answer | added | Praveen Kumar BS | timeline score: -1 | |
| Aug 19, 2019 at 6:25 | comment | added | Ed Morton | See stackoverflow.com/q/45772525/1745001, unix.stackexchange.com/q/169716/133219, porkmail.org/era/unix/award.html, porkmail.org/era/unix/award.html, mywiki.wooledge.org/BashFAQ/082, and mywiki.wooledge.org/BashFAQ/001 for descriptions of most of the issues in your script. | |
| Aug 19, 2019 at 5:56 | comment | added | Kusalananda♦ |
This is most likely a due to filelist.txt being a DOS text file. The patterns (filenames) in that file would then have an extra carriage-return character at the end, which would never match in the out.log file. OR there are simply no matches in out.log (you haven't shown an example of a log entry that ought to be matched).
|
|
| Aug 19, 2019 at 5:54 | history | edited | Kusalananda♦ | CC BY-SA 4.0 |
Move text from "answer" into question
|
| Aug 19, 2019 at 4:41 | comment | added | cas |
without at least sample of the contents of both filelist.txt and out.log it's impossible to tell why neither the for loop nor the grep are working. @GordonDavisson's guess about dos/windows text files is a pretty good one and may be the source of the problem.
|
|
| Aug 19, 2019 at 4:35 | comment | added | Gordon Davisson |
Is filelist.txt in DOS/Windows text format by any chance? If that's not the problem, try putting set -x before the loop so it'll print out what the shell thinks is happening and you can see what's different from what you expect.
|
|
| Aug 19, 2019 at 4:03 | comment | added | cas |
this question comes up a lot, but i can't find an exact dupe at the moment. grep can do this (with the -f option) without needing a shell for loop. try grep -i -f filelist.txt out.log > result.txt
|
|
| Aug 19, 2019 at 3:55 | review | First posts | |||
| Aug 19, 2019 at 4:22 | |||||
| Aug 19, 2019 at 3:54 | history | asked | Dwija | CC BY-SA 4.0 |