Today I received a request that a string be included in the result of the script execution and asked to find out.
The idea I gave was to write the text in an appended way according to the name of the script and the result, and then find the corresponding content from the text.
The other side of the train of thought is to execute the results to judge, on their own to achieve this way
The first is to write the script according to the directory, here is the content of the Echo $i written in the script. That is, the script has execution results.
#!/bin/Bashsh_dir=sh_dircd $SH _dir for in $ (seq); do Echo " Echo $i "> $i.sh done
Then the loop executes and looks for the script, which is all traversed once and can be done by itself only to find the first one to terminate.
1#!/bin/Bash2Sh_dir=Sh_dir3 forRunshinch`ls$SH _dir |grep.SH`;4 Do5 Echo$runsh6result= './$SH _dir/$runsh '7 Echo$result8 Echo$result |grep '8'9 Ten if[$?-ne0 ]; One Then A Echo "" - Else - Echo "find it in $runsh" the fi - Done
The 5th and 7th lines can be commented out, and the display is clearer.
I think it might be a bit faster to implement Python. I think I've been learning python for a longer time.
Pseudo-code is similar to this, the for loop iterates through the executable file, then stores the result, using the if to make a comparison.
[Shell] Implements script execution results matching a string