grepstr()
{
grep "$1 $2" $TMP/"ORACLE_SID"_dbmode.txt > /dev/null 2>$1
}
- What is the meaning of the above command?
- What are
$1and$2? Why it is necessary? - Is there any alternatives for using
$1and$2?
|
feedback
|
|
Is that exactly what the code looks like? As it is, it is a function that takes two arguments, let's say they're Then it reads a file called This is quite confusing, so I don't think this is the actual code. I would imagine it is actually this:
Changes:
If so, it could be used two ways:
for example:
would make it print (see below) any lines in the file
(Also, technically The second way is:
in which case it will print any lines matching string_or_pattern in That seems less likely, but it is possible, depending how the code is used. It could also be called like this:
but that would read from standard input (e.g. the keyboard by default), and print any lines that contained If my guess is right, the code isn't
So if the output isn't important,
or like this:
to only execute some code if there was a match. In answer to the other part of your question, yes, it could be changed to
The I think that way would be better, because it would be more flexible. On the other hand, if it does require two arguments for some reason I can't think of, then perhaps | ||||
|
feedback
|
|
For example, running
actually runs command
and redirects output to Basically, when you run script (or function), | |||
|
feedback
|