08-07-2012
How to analyse results of grep
Hi all,
I'm working with a peice of software that runs on Linux that allows planning trips in cars through maps. This software has different variations depending on the type of car, e.g. BMW, Audi, Hyundai, etc... Each variation has a dependency on common external components that are not compiled with the main source code and must be installed seperately in /local_components/... Some variations also have dependencies on components that are not required by other variations.
The standard way of knowing which components to install for the customer is to run a shell script that sets environment variables based on what variant you are wishing to build set in a config spec. This will set variables for all the external components required for compilation and runtime. The component variables have a standard naming convention based on versions. So there are some components that are upto version 2.0 and some with version 1.0, etc. Naming convention e.g. GPS_COMP_VER_2.0, COMMON_UTILITIES_VER_4.0. Once I determine what components are required by manually grepping the environment variables script I need to manually install the required components one by one by using rpm -i
I need to create a shell script to grep this script for all required components, so far I have this: env | grep '_VER_[0-9\-]*$'
I want to be able to analyse the results of this grep one by one and to then find the rpm package in a component library on a server. based on the version and install it automatically.
How would you suggest I go about this task? I am relatively new to shell scripting and am still learning on the job. So, any advice will be much appreciated!
Thanks!
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello,
Perhaps someone here can help with this. I'd like to grep a plain text file for a word and output each line containing a word found to a seperate line instead of back to back.
Examples:
Basic command:
cat file.txt > grep -i CAT > results.txt
file.txt:
The cat said meow
The... (7 Replies)
Discussion started by: sysera
7 Replies
2. Shell Programming and Scripting
I need help to further reduce the output shown below. I want to be able to only return the paragraph where the 'Database alias' is exactly equal to DBIHP. I do not want the other paragraphs being shown below.
$ echo $dbalias
DBIHP
$ db2 list db directory|grep -p 'Database alias ... (2 Replies)
Discussion started by: priceb
2 Replies
3. UNIX for Dummies Questions & Answers
Hi
I need to search for matching strings in a database and I want to print out all files that matches in "detail", which means that I want the output to contain datum of last saving. I only get the grep function tp print the actual file names which is not enough since the database is to large... (14 Replies)
Discussion started by: slire
14 Replies
4. Shell Programming and Scripting
Hi All,
I'm struggling with a problem that I'm wondering (and hoping!) that someone can help me with.
I have a number of .xml files which I'm using grep to search for the string 'include'. I need to extract the value of the include from the grep result.
For example, on any given file, I... (2 Replies)
Discussion started by: Steve_altius
2 Replies
5. UNIX for Dummies Questions & Answers
Hi,
I am currently reading a tar file and searching for a particular word using grep e.g. Plane. At the moment, if a sentence is found with the word "Plane" the sentence itself is piped to another file.
Here is the code i am using;
for jar in 'cat jar_file.tar'; do
tar -tvf... (3 Replies)
Discussion started by: crunchie
3 Replies
6. Shell Programming and Scripting
Here is one I am baffled with; I have not used unix for a while and now that I am back it has been fun remembering and I have enjoyed it, for the most past. this is in ksh.
I need to search in a file for the line with X1 and cut columns 20-25, put them into a variable, added them (dollar... (3 Replies)
Discussion started by: CougarMutt
3 Replies
7. Shell Programming and Scripting
Hello guys,
I have been looking around but can't find the answer to my problem:
If the grep command displays no results, print "no results have been found" and increment x. But if the grep command find something, do nothing.
if
echo "no results have been found $x"
x=`expr $x + 1 `... (3 Replies)
Discussion started by: Benou
3 Replies
8. UNIX for Dummies Questions & Answers
Hi,
Am running the command below to search for files that contains a certain string.
grep -il "shutdown" `find . -type f -mtime -1 -print` | grep "^./scripts/active"
How do I get it to do a ls -l on the list of files? I tried doing ls -l `grep -il "shutdown" `find . -type f -mtime -1... (5 Replies)
Discussion started by: newbie_01
5 Replies
9. Shell Programming and Scripting
hi,
let's say we have input in files test1.txt, test2.txt, text3.txt ... ... ... ('...' means more files & lines not just 'dots')
test1.txt has:
A
B
C
D
...
...
...
test2.txt has
A
B
C
D
...
...
... (4 Replies)
Discussion started by: msonoth
4 Replies
10. Shell Programming and Scripting
Hi,
i have a file hello.log which as several line that look like the below
2015-12-07 09:46:56 0:339 120.111.12.12 POST /helloWorld
2015-12-07 09:46:57 0:439 122.111.12.12 POST /helloWorld
....
when i grep expecting to see results like the below.
... (6 Replies)
Discussion started by: mohtashims
6 Replies
LEARN ABOUT SUNOS
wsreg_get_child_components
wsreg_add_child_component(3WSREG) Product Install Registry Library Functions wsreg_add_child_component(3WSREG)
NAME
wsreg_add_child_component, wsreg_remove_child_component, wsreg_get_child_components - add or remove a child component
SYNOPSIS
cc [flag ...] file ...-lwsreg [library ...]
#include <wsreg.h>
int wsreg_add_child_component(Wsreg_component *comp, const Wsreg_component *childComp);
int wsreg_remove_child_component(Wsreg_component *comp, const Wsreg_component *childComp);
Wsreg_component **wsreg_get_child_components(const Wsreg_component *comp);
DESCRIPTION
The wsreg_add_child_component() function adds the component specified by childComp to the list of child components contained in the compo-
nent specified by comp.
The wsreg_remove_child_component() function removes the component specified by childComp from the list of child components contained in the
component specified by comp.
The wsreg_get_child_components() function returns the list of child components contained in the component specified by comp.
RETURN VALUES
The wsreg_add_child_component() function returns a non-zero value if the specified child component was successfully added; otherwise, 0 is
returned.
The wsreg_remove_child_component() function returns a non-zero value if the specified child component was successfully removed; otherwise,
0 is returned.
The wsreg_get_child_components() function returns a null-terminated array of Wsreg_component pointers that represents the specified compo-
nent's list of child components. If the specified component has no child components, NULL is returned. The resulting array must be
released by the caller through a call to wsreg_free_component_array(). See wsreg_create_component(3WSREG).
USAGE
The parent-child relationship between components in the product install registry is used to record a product's structure. Product struc-
ture is the arrangement of features and components that make up a product. The structure of installed products can be displayed with the
prodreg GUI.
The child component must be installed and registered before the parent component can be. The registration of a parent component that has
child components results in each of the child components being updated to reflect their parent component.
Read access to the product install registry is required in order to use these functions because these relationships are held with light-
weight component references that can only be fully resolved using the registry contents.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|MT-Level |Unsafe |
+-----------------------------+-----------------------------+
SEE ALSO
prodreg(1M), wsreg_can_access_registry(3WSREG), wsreg_create_component(3WSREG), wsreg_initialize(3WSREG), wsreg_register(3WSREG),
wsreg_set_parent(3WSREG), attributes(5)
SunOS 5.10 22 Sep 2000 wsreg_add_child_component(3WSREG)