Bug 59222
| Summary: | grep not functioning properly in while loop | ||
|---|---|---|---|
| Product: | [Retired] Red Hat Linux | Reporter: | Brian Hanks <brice> |
| Component: | grep | Assignee: | Bernhard Rosenkraenzer <bero> |
| Status: | CLOSED DUPLICATE | QA Contact: | Aaron Brown <abrown> |
| Severity: | medium | Docs Contact: | |
| Priority: | medium | ||
| Version: | 7.2 | CC: | brice |
| Target Milestone: | --- | ||
| Target Release: | --- | ||
| Hardware: | i686 | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | Bug Fix | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2002-02-02 19:26:19 UTC | Type: | --- |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
grep is doing the right thing, your script isn't. You're expecting read to do things it actually doesn't, see "bug" #19747. *** This bug has been marked as a duplicate of 19747 *** Why does "read" not function the way I "expect" it to? When I run this same test on Solaris 7, Solaris 8, or HP-UX 11 it works exactly as I would "expect". Linux is the only place where I have this problem. |
From Bugzilla Helper: User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.7) Gecko/20011226 Description of problem: The following code produces valid results from the command line but not in a ksh,pdksh,bash,or zsh script: #!/bin/ksh servers_file=/tmp/servers.txt file=/tmp/testfile.txt cat ${servers_file} | while read server do grep "${server}" ${file} done Include two host names in the servers.txt file. Include two fields in the testfile.txt, the first is a full path to any file and the second is a hostname separated by a pipe delimiter. Version-Release number of selected component (if applicable): How reproducible: Always Steps to Reproduce: 1. Run the simple script and observe no result. 2. Run from command line and observe valid results. Actual Results: It did not return valid data in the script. Expected Results: It should have produced the same results from both places. Additional info: