only the weirdest thing happened with me just now. I was debugging a shell script and I found that a step that was supposed to execute later was getting executed prior to another step for no reason. You know any ?
i mean have a look at the following command-
[if $DISPLAY xstatus | $GREP "$right...$right" ]
here it tries to grep first(and hence gives an ambiguous output) and later displays the xstatus.(It should do the opposite,right?)
also any idea what the command which frsh does ? it gives no output on my system. But it sure does something.
Yes, the "DISPLAY" command should execute and pipe it's output to grep. It would help if you could post the whole script, or at least the portions that include the assignment to the DISPLAY variable. It might also help to post the output.
Not knowing exactly what command has been assigned to DISPLAY, I can only guess, and my first thought is that the command's normal output is to standard error and not standard out. This situation could exhibit the behaviour you describe as grep might appear to execute first (failing because of an immediate end of file on standard input?) and the standard error from the command still appearing on the tty device.
Again, that is only a guess, and posting more of the script will certainly help people answer your question.
again please consider something like this "cat abc.txt | grep 123"
All I wanna know is if there's any way that script greps first and cats later ?
We can take my script later on because its a little confidential. I cannot disclose it. Not even a snippet. But thats the crux of it !
hope ya'll understand
prints any line in the file abc.txt that contains the string "123". We understand that the command:
grep 123 abc.txt
does exactly the same thing much more efficiently.
You're saying that the command:
[if $DISPLAY xstatus | $GREP "$right...$right" ]
is running whatever $GREP expands to before it runs the command [if . This will probably give a syntax error because you most likely do not have a utility named [if . Since you won't tell us what error was displayed, you haven't told us what system you're using, you haven't told us what shell you're using, and you won't even use CODE tags; you're asking us to work with our hands tied behind our backs. I can guess that you would probably have better luck with:
if [ $DISPLAY xstatus | $GREP "$right...$right" ]
but there is no way that we can guess whether or not that might do what you want done with the information you have provided.