Sponsored Content
Top Forums Shell Programming and Scripting Parsing a file based on next line Post 302923022 by ghostdog74 on Wednesday 29th of October 2014 09:41:12 PM
Old 10-29-2014
Whenever you need to solve some thing, try to design your approach first before writing code.

Pseudocode:
Code:
while read each line from file 
do
   if start with ID then
       save the line to a variable=var
   fi
   if start with CC then
       print the variable=var       
   fi
done

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parsing line out of a file, please help !!

Hello, I have a file with several lines for example; I need to extract a line radiusAuthServTotalAccessRequests.0 = 0 and I don't have line #s in the file. I need to write a script to extract the above line, put a date beside it and parse this line out to another directory / file. How... (5 Replies)
Discussion started by: xeniya
5 Replies

2. Shell Programming and Scripting

parsing a file by line

I'm trying to make a script that will read variables line by line from a flatfile i.e. $ cat testfile dbfoo sfoo prifoo poofoo bfoo osfoo dbfoo2 sfoo2 prifoo2 poofoo2 bfoo2 osfoo2 $ The first pass of the script through the flatfile I want: $1=dbfoo $2=sfoo... (6 Replies)
Discussion started by: loadnabox
6 Replies

3. Shell Programming and Scripting

Parsing Log File Based on Date & Error

I'm still up trying to figure this out and it is driving me nuts. I have a log file which has a basic format of this... 2010-10-10 22:25:42 Init block 'UA Deployment Date': Dynamic refresh of repository scope variables has failed. The ODBC function has returned an error. The database... (4 Replies)
Discussion started by: k1ko
4 Replies

4. Shell Programming and Scripting

parsing file based on characters/bytes

I have a datafile that is formatted as fixed. I know that each line should contain 880 characters. I want to separate the file into 2 files, one that has lines with 880 characters and the other file with everything else. Is this possible ? (9 Replies)
Discussion started by: cheeko111
9 Replies

5. UNIX for Dummies Questions & Answers

Parsing file, reading each line to variable, evaluating date/time stamp of each line

So, the beginning of my script will cat & grep a file with the output directed to a new file. The data I have in this file needs to be parsed, read and evaluated. Basically, I need to identify the latest date/time stamp and then calculate whether or not it is within 15 minutes of the current... (1 Reply)
Discussion started by: hynesward
1 Replies

6. Shell Programming and Scripting

Replace line in file with line in another file based on matching string

Hi I am not the best scripter in the world and have run into a issue which you might be able to guide me on... I have two files. File1 : A123, valueA, valueB B234, valueA, valueB C345, valueA, valueB D456, valueA, valueB E567, valueA, valueB F678, valueA, valueB File2: C345,... (5 Replies)
Discussion started by: luckycharm
5 Replies

7. Shell Programming and Scripting

Replace and add line in file with line in another file based on matching string

Hi, I want to achieve something similar to what described in another post: The difference is I want to add the line if the pattern is not found. File 1: A123, valueA, valueB B234, valueA, valueB C345, valueA, valueB D456, valueA, valueB E567, valueA, valueB F678, valueA, valueB ... (11 Replies)
Discussion started by: jyu3
11 Replies

8. Shell Programming and Scripting

Replace line in file with line in another file based on matching string

HI Can any one guide me how to achieve this task. I have 2 files env.txt #Configuration.Properties values identity_server_url = http://identity.test-hit.com:9783/identity/service/user/register randon_password_length = 6 attachment_file_path = /pass/temp/attachments/... (1 Reply)
Discussion started by: nikilbr86
1 Replies

9. Shell Programming and Scripting

Parsing a file based on positional constraints

I have a list file1 like dog cow fox cat fish duck crowI want to classify the elements of file1 based on constrains applied on file2. Additionally the number of elements (words) in the each line of file2 is not fixed. This is my file2 cow cat fox dog cow fox dog fish crow fox dog cat ... (5 Replies)
Discussion started by: sammy777
5 Replies

10. Shell Programming and Scripting

File Parsing based on a character in a specific field

Hi All, I'm having a hard time finding a starting point for my issue. I have a 30k line file (fspsec.txt) that I would like to parse into smaller files based on any character existing in field 1. ACCOUNTANT LEVEL 1 (ACCT.ACCOUNTANT) OPERATORS: DOEJO (418) TOOLS: Branch Maintenance ... (2 Replies)
Discussion started by: aahlrich
2 Replies
RNEWS(1)						      General Commands Manual							  RNEWS(1)

NAME
rnews - receive news from a UUCP connection SYNOPSIS
rnews [ -h host ] [ -v ] [ -U ] [ -N ] [ -S master ] [ input ] DESCRIPTION
Rnews reads messages typically queued by a UUCP newsfeed and sends them to the local InterNetNews server. The message is read from the specified input file, or standard input if no input is named. When sent over UUCP, Usenet articles are typically joined in a single batch to reduce the UUCP overhead. Batches can also be compressed, to reduce the communication time. If a message does not start with a number sign (``#'') and an exclamation point, then the entire input is taken as a single news article. If it does start with with those two characters, then the first line is read and interpreted as a batch command. If the command is ``#! rnews nnn'' where nnn is a number, then the next nnn bytes (starting with the next line) are read as a news article. If the command is ``#! cunbatch'' then the rest of input is fed to the compress(1) program with the ``-d'' flag to uncompress it, and the output of this pipe is read as rnews's input. This is for historical compatibility -- there is no program named cunbatch. A compressed batch will start with a ``#! cunbatch'' line, then contain a series of articles separated by ``#! rnews nnn'' lines. If the command is any other word, then rnews will try to execute a program with that name in the directory /usr/lib/news/rnews. The batch will be fed into the program's standard input, and the standard output will be read back as input into rnews. If rnews detects any problems with an article such as a missing header, or an unintelligible reply from the server, it will save a copy of the article in the /var/spool/news/in.coming/bad directory. OPTIONS
-S If the ``-S'' flag is used, then rnews will connect to the specified host. If the flag is not used, it will try to connect to the server by opening a Unix-domain stream connection. If that fails, it will try to open a TCP connection to the default remote server. -U If the server is not available, the message is spooled into a new file created in the /var/spool/news/in.coming directory. The ``-U'' flag may be used to send all spooled messages to the server once it becomes available again, and can be invoked regularly by cron(8). -N Normally, if unpacking the input fails it is re-spooled to /var/spool/news/in.coming for another attempt later. If the ``-N'' flag is used then no such re-spooling is done and rnews exits with status value ``9'' to indicate this. -v If the ``-v'' flag is used, it will print a notice of all errors on the standard error, naming the input file (if known) and print- ing the first few characters of the input. Errors are always logged through syslog(3). -h If the ``-h'' flag is given, or failing that, the enviroment variable UU_MACHINE is set, then rnews will log the Message-ID, and host, for each article offered to the server via syslog(3). Logging will only be done if the value is not an empty string. BUGS
Rnews cannot process articles that have embedded 's in them. HISTORY
Written by Rich $alz <rsalz@uunet.uu.net> for InterNetNews. This is revision 1.23, dated 1996/11/08. SEE ALSO
innd(8). RNEWS(1)
All times are GMT -4. The time now is 03:00 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy