Syntax
b=unixgrep(sstr,[greps])
Input Parameter
sstr : | | search string |
greps : | | search file |
Output Parameter
Examples
unixgrep ('PLcircle')
Copyright 2020-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth
Algorithm (Workflow)
This function, unixgrep
, is designed to search for a specific string within files, similar to the Unix grep
command. It is part of the SolidGeometry library.
Input Parameters
- sstr: The search string that the function will look for within the files.
- greps: (Optional) The file or files to search within. If not provided, it defaults to all files with the pattern '*.*'.
Output
- b: The result of the grep operation, which is typically the lines from the files that contain the search string.
Algorithm Steps
- The function begins by determining the files to search. It uses the helper function
getfuncparams
to retrieve the greps
parameter. If greps
is not provided, it defaults to '*.*', meaning all files.
- The function constructs a Unix command string using
sprintf
. This command uses the grep
command to search for the sstr
within the specified greps
files.
- The constructed command is executed using the
unix
function, which runs the command in the system's shell.
- The output of the
unix
command is captured, and the relevant result is stored in the variable b
.
Example Usage
To search for the string 'PLcircle' in all files, you would call the function as follows:
unixgrep('PLcircle')
This will search for 'PLcircle' in all files matching the pattern '*.*' and return the lines containing this string.
Algorithm explaination created using ChatGPT on 2025-08-18 22:06. (Please note: No guarantee for the correctness of this explanation)
Last html export of this page out of FM database by TL: 2025-09-21