Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hello,
Before I am writing a record to a file, I'd like to check to see if that recrod already exists in the file. If it is already in the file, the record will be ignored, otherwise it will be writen to the file. I tought that this is going to be a simple solution by using "grep" but I couldn't get it to work. here is a sample input record:
"ouh 123 ouhlaptop"I was trying to use grep -q command to see if the entire line above is in the file but it didn't work.
Please help!

Without seeing your script, it's hard to tell what your problem is. But a possible problem is you are trying to grep a file that is presently open for writing, i.e.:
while true do . . . done < inputfile > outputfileIn the above example, you might be greping the outputfile for something that the script previously wrote, but the shell is still buffering data so grep doesn't see it. All the data is completely written to the file until the while loop completes.
If you post your script, I'll give you an opinion.

![]() |
![]() |
![]() |
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |