05-13-2008
read a file and compare
hi
how can i read a file using the unix script and check for one or more field value for a predefined status/value
for example : the file contains the following text
Name IP Address/Mask Type Connection Status
mgmt-eth0(1) 10.7.225.5/24 mgmt Ethernet Up
lo1(1) 127.0.0.1/8 mgmt Loopback Up
i need to check the status column value whether it is Up. if its not it has to be logged in a separate file.
thanks
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
Currently I am coding up a nasty way of reading file input using *cat* rather than *read*. My text input looks like
TextA 100
TextB 110
TextC 120
Currently I am using cat |while read line to read the first column and second column fields.
cat foo.txt|while read line
do
... (1 Reply)
Discussion started by: ahjiefreak
1 Replies
2. Shell Programming and Scripting
i want a shell script to read the a list of numbers from a file and compare with a unique number with the list.
FOR EXAMPLE :
abc.lst file contains d following
2343
3214
45654
563456
5436
Unique number is 2342 (6 Replies)
Discussion started by: pgmfourms
6 Replies
3. Shell Programming and Scripting
Hi ,
I have a CSV file ( file.csv) with some data as
below:
A,1,abc,x,y,z,,xyz,20100101,99991231
A,1,abc,x,y,z,234,xyz,20100101,99991231
I have to delete the duplicate line based on
unique identifiers which are values in the
fields- 2,3,4,8.These coulmns in both the rows
have same... (6 Replies)
Discussion started by: Sheel
6 Replies
4. Shell Programming and Scripting
Hello,
I have this file that sometime contains 0 lines and sometimes 1 or more.
It's supposed to then put the result (could be 0 or 1 or 2 or more) into a variable.
Then it's supposed to echo using an if else statement depending on the value of the variable.
flagvar='wc -l $tempfile |... (1 Reply)
Discussion started by: script_op2a
1 Replies
5. Shell Programming and Scripting
Hi forumers,
How is it going. Ok i need some advice on the following problem.
I have 2 files to read and compare data.FileA and FileB. FileA will return either status 1 or 0. FileB on the other hand is trickier and has the following details:-
Count DeviceID CurrentStatus ... (7 Replies)
Discussion started by: prakash1111
7 Replies
6. UNIX for Dummies Questions & Answers
Hello All,
i am a newbie and need some help when reading a csv file in a bourne shell script. I want to read 10 lines, then wait for a minute and then do a reading of another 10 lines and so on in the same way. I want to do this till the end of file.
Any inputs are appreciated
... (3 Replies)
Discussion started by: victor.s
3 Replies
7. Shell Programming and Scripting
I have a file which has following content:
NAME=ora.DG1.dg
TYPE=ora.diskgroup.type
TARGET=ONLINE
STATE=ONLINE
NAME=ora.DG2.dg
TYPE=ora.diskgroup.type
TARGET=ONLINE
STATE=ONLINE
NAME=ora.DG3.dg
TYPE=ora.diskgroup.type
TARGET=ONLINE
STATE=ONLINE
NAME=ora.DG4.dg... (7 Replies)
Discussion started by: rcc50886
7 Replies
8. Shell Programming and Scripting
Hi all,
I have a log file say Test.log that gets updated continuously and it has data in pipe separated format. A sample log file would look like:
<date1>|<data1>|<url1>|<result1>
<date2>|<data2>|<url2>|<result2>
<date3>|<data3>|<url3>|<result3>
<date4>|<data4>|<url4>|<result4>
What I... (3 Replies)
Discussion started by: pat_pramod
3 Replies
9. UNIX for Dummies Questions & Answers
How would I go about having ncurses look at a coordinate, read what character is there, and see if it is the same as an other character? I've been trying to use inch(), but I don't think I'm doing it right. Here's the portion of the code I'm struggling with.
//Code to scroll left
chtype... (0 Replies)
Discussion started by: mitsopy
0 Replies
10. UNIX for Beginners Questions & Answers
Hello Guys
I need to read and compare two file, one file contains hostname, and others contain hostname and IP@,
and the objective is to read each file and compare if line in file1 equal to first word in the second file2
file1
file2
this is my first code
fqdn_hosts=list.txt... (2 Replies)
Discussion started by: Abdellah
2 Replies
LEARN ABOUT REDHAT
genders_testquery
GENDERS_TESTQUERY(3) LIBGENDERS GENDERS_TESTQUERY(3)
NAME
genders_testquery - query genders database for a set of nodes
SYNOPSIS
#include <genders.h>
int genders_testquery(genders_t handle, const char *node, const char *query);
DESCRIPTION
genders_testquery() tests if the node pointed to by node meets the conditions specified in the query. If node is NULL, the current node is
tested. Queries are based on the union, intersection, difference, or complement of genders attributes and values. The query is passed as
a string through the query parameter. The set operation union is represented by two pipe symbols ('||'), intersection by two ampersand
symbols ('&&'), difference by two minus symbols ('--'), and complement by a tilde ('~'). Set operations are performed left to right.
Parentheses may be used to change the order of operations. A list of query examples are listed below. A NULL query retrieves all nodes
from the genders database.
EXAMPLES
The following are example queries that can be passed to genders_testquery().
Test if a node contains the mgmt or login attribute:
"mgmt||login"
Test if a node is not a login node:
"all--login"
Test if a node is both a login node and ntp server:
"login&&ntpserv"
Test if a node is not a mgmt or login node:
"~(mgmt||login)"
RETURN VALUES
If the node as met the conditions of the query, 1 is returned. 0 is returned if the node does not meet the conditions of the query. On
error, -1 is returned, and an error code is returned in handle. The error code can be retrieved via genders_errnum(3) , and a description
of the error code can be retrieved via genders_strerror(3). Error codes are defined in genders.h.
ERRORS
GENDERS_ERR_NULLHANDLE
The handle parameter is NULL. The genders handle must be created with genders_handle_create(3).
GENDERS_ERR_NOTLOADED
genders_load_data(3) has not been called to load genders data.
GENDERS_ERR_PARAMETERS
An incorrect parameter has been passed in.
GENDERS_ERR_SYNTAX
There is a syntax error in the query.
GENDERS_ERR_OUTMEM
malloc(3) has failed internally, system is out of memory.
GENDERS_ERR_MAGIC
handle has an incorrect magic number. handle does not point to a genders handle or handle has been destroyed by genders_han-
dle_destroy(3).
GENDERS_ERR_INTERNAL
An internal system error has occurred.
FILES
/usr/include/genders.h
SEE ALSO
libgenders(3), genders_handle_create(3), genders_load_data(3), genders_errnum(3), genders_strerror(3)
LLNL
June 2004 GENDERS_TESTQUERY(3)