08-29-2002
pulling the following line from a file
I have return files from a process that has then original input record followed on the next line by a response record..either AA,........... for accepted or EE,.......... for errored.
i.e
11,new,123
AA,accepted
12,exist,443
EE,rejected
13,old,223
AA,accepted
I want to write a small script that will return the row and it's response to a separate file.
I.e. I tell the script I want the records that start 11 and their responses and I get the first two lines above. I can do the pattern matching etc to get the first line - but I am having trouble getting the second line to come back too.
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
Hi,
I have a file that contains 1400 lines similar to the one shown below:
NAME=sara, TOWN=southampton, POSTCODE=SO18777, EMAIL=sara@hotmail.com, PASSWORD=asjdflkjds etc etc (note: this is one line).
Each line has the same fields, but on each line they are in a different order. Eg. the line... (2 Replies)
Discussion started by: Saz
2 Replies
2. Shell Programming and Scripting
I would like to pull a column from a file and place it in a variable:
The file would look like this:
N.Korea gibberish garbage
S.Korea gibberish garbage
USA gibberish garbage
Iraq gibberish garbage
Canada gibberish garbage
and items in the first... (8 Replies)
Discussion started by: dangral
8 Replies
3. Shell Programming and Scripting
I saw a few posts close to what i want to do, but they didn't look like they would work exactly.. or I need to think out of the box on this.
I have a file that I keep server stats in for my own performance analysis. this file has the output from many commands in it (uptime, vmstats, ps, swap... (2 Replies)
Discussion started by: MizzGail
2 Replies
4. UNIX for Dummies Questions & Answers
I have AIX 5.1
This may sound like a really dumb question but I have never done this before.
I would like to pull a file off a backup tape and put back on the AIX
is this as simple as as doing a
mount /dev/rmt1
then the file name that is on the tape /dump/rpt/xxxxxx
Do I just copy it... (14 Replies)
Discussion started by: rocker40
14 Replies
5. UNIX for Dummies Questions & Answers
Hi
I have a file called as MSD.DAT. This file is present at a directory on a server.
www.ta.ibhsv.somewhere.com/rahdf/MSD.DAT
Now, I want to get this file from this server to my Linux box. I need to write a script that uses https to get the file.
Please help how to achieve this.
... (3 Replies)
Discussion started by: infyanurag
3 Replies
6. Shell Programming and Scripting
Hi all,
I am fairly new to scripting, but I do try and script as much as possible but the more advanced stuff does tend to boggle my mind a bit.
I am at a bit of a loss with this one.
I get entries in my DNS logs, like the below:
I want to extract only the IP address, without the hashes... (5 Replies)
Discussion started by: codenjanod
5 Replies
7. Shell Programming and Scripting
Hi,
I have a requirment where I need to pull different columns from a .csv file.
Here is the sample of the csv file.
account,item,flag1,flag2,flag3,flag4,flag5,......feed,tran
I will be have a config.txt file which will have the following information.
item,flag5,flag10,feed,tran... (2 Replies)
Discussion started by: akdevula
2 Replies
8. UNIX for Dummies Questions & Answers
Hello all,
I'm working on a general script for something at work. I'm an up-and-comer backup for a Shell Scripter this company has had for 35 years lol. Anyway, I have a config file I'm trying to pull Variables from as the Config File is used for multiple scripts. Does the below make sense and... (7 Replies)
Discussion started by: phunk
7 Replies
9. Shell Programming and Scripting
I'm scanning a list of emails- I need to pull 2 pieces of data, then move to the next file:
Sender's Email Address
Email Date
I need these to be outputted into a single column- separated by a ",". Like this:
Email1's Address, Email1's Date Stamp
Email2's Address, Email2's Date Stamp... (4 Replies)
Discussion started by: sudo
4 Replies
10. Shell Programming and Scripting
I am connecting to another server through sftp. I am running one batch script to pull file from another server. sometimes i am receiving partial files. I am using below commands in batch script.
ls -ltr new.txt
mget new.txt
bye
The file is of 1 MB only.In most of the cases , i received... (6 Replies)
Discussion started by: srinath01
6 Replies
LEARN ABOUT MINIX
rpmatch
RPMATCH(3) Linux Programmer's Manual RPMATCH(3)
NAME
rpmatch - determine if the answer to a question is affirmative or negative
SYNOPSIS
#include <stdlib.h>
int rpmatch(const char *response);
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
rpmatch():
Since glibc 2.19:
_DEFAULT_SOURCE
Glibc 2.19 and earlier:
_SVID_SOURCE
DESCRIPTION
rpmatch() handles a user response to yes or no questions, with support for internationalization.
response should be a null-terminated string containing a user-supplied response, perhaps obtained with fgets(3) or getline(3).
The user's language preference is taken into account per the environment variables LANG, LC_MESSAGES, and LC_ALL, if the program has called
setlocale(3) to effect their changes.
Regardless of the locale, responses matching ^[Yy] are always accepted as affirmative, and those matching ^[Nn] are always accepted as neg-
ative.
RETURN VALUE
After examining response, rpmatch() returns 0 for a recognized negative response ("no"), 1 for a recognized positive response ("yes"), and
-1 when the value of response is unrecognized.
ERRORS
A return value of -1 may indicate either an invalid input, or some other error. It is incorrect to only test if the return value is
nonzero.
rpmatch() can fail for any of the reasons that regcomp(3) or regexec(3) can fail; the cause of the error is not available from errno or
anywhere else, but indicates a failure of the regex engine (but this case is indistinguishable from that of an unrecognized value of
response).
ATTRIBUTES
For an explanation of the terms used in this section, see attributes(7).
+----------+---------------+----------------+
|Interface | Attribute | Value |
+----------+---------------+----------------+
|rpmatch() | Thread safety | MT-Safe locale |
+----------+---------------+----------------+
CONFORMING TO
rpmatch() is not required by any standard, but is available on a few other systems.
BUGS
The rpmatch() implementation looks at only the first character of response. As a consequence, "nyes" returns 0, and "ynever; not in a mil-
lion years" returns 1. It would be preferable to accept input strings much more strictly, for example (using the extended regular expres-
sion notation described in regex(7)): ^([yY]|yes|YES)$ and ^([nN]|no|NO)$.
EXAMPLE
The following program displays the results when rpmatch() is applied to the string given in the program's command-line argument.
#define _SVID_SOURCE
#include <locale.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
int
main(int argc, char *argv[])
{
if (argc != 2 || strcmp(argv[1], "--help") == 0) {
fprintf(stderr, "%s response
", argv[0]);
exit(EXIT_FAILURE);
}
setlocale(LC_ALL, "");
printf("rpmatch() returns: %d
", rpmatch(argv[1]));
exit(EXIT_SUCCESS);
}
SEE ALSO
fgets(3), getline(3), nl_langinfo(3), regcomp(3), setlocale(3)
COLOPHON
This page is part of release 4.15 of the Linux man-pages project. A description of the project, information about reporting bugs, and the
latest version of this page, can be found at https://www.kernel.org/doc/man-pages/.
GNU
2017-09-15 RPMATCH(3)