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
Taint(3pm)						User Contributed Perl Documentation						Taint(3pm)

NAME
Test::Taint - Tools to test taintedness VERSION
Version 1.04 $Header: /home/cvs/test-taint/Taint.pm,v 1.16 2004/08/10 03:06:57 andy Exp $ SYNOPSIS
taint_checking_ok(); # We have to have taint checking on my $id = "deadbeef"; # Dummy session ID taint( $id ); # Simulate it coming in from the web tainted_ok( $id ); $id = validate_id( $id ); # Your routine to check the $id untainted_ok( $id ); # Did it come back clean? ok( defined $id ); DESCRIPTION
Tainted data is data that comes from an unsafe source, such as the command line, or, in the case of web apps, any GET or POST transactions. Read the perlsec man page for details on why tainted data is bad, and how to untaint the data. When you're writing unit tests for code that deals with tainted data, you'll want to have a way to provide tainted data for your routines to handle, and easy ways to check and report on the taintedness of your data, in standard Test::More style. "Test::More"-style Functions All the "xxx_ok()" functions work like standard "Test::More"-style functions, where the last parm is an optional message, it outputs ok or not ok, and returns a boolean telling if the test passed. taint_checking_ok( [$message] ) Test::More-style test that taint checking is on. This should probably be the first thing in any *.t file that deals with taintedness. tainted_ok( $var [, $message ] ) Checks that $var is tainted. tainted_ok( $ENV{FOO} ); untainted_ok( $var [, $message ] ) Checks that $var is not tainted. my $foo = my_validate( $ENV{FOO} ); untainted_ok( $foo ); tainted_ok_deeply( $var [, $message ] ) Checks that $var is tainted. If $var is a reference, it recursively checks every variable to make sure they are all tainted. tainted_ok_deeply( \%ENV ); untainted_ok_deeply( $var [, $message ] ) Checks that $var is not tainted. If $var is a reference, it recursively checks every variable to make sure they are all not tainted. my %env = my_validate( \%ENV ); untainted_ok_deeply( \%env ); Helper Functions These are all helper functions. Most are wrapped by an "xxx_ok()" counterpart, except for "taint" which actually does something, instead of just reporting it. taint_checking() Returns true if taint checking is enabled via the -T flag. tainted( $var ) Returns boolean saying if $var is tainted. tainted_deeply( $var ) Returns boolean saying if $var is tainted. If $var is a reference it recursively checks every variable to make sure they are all tainted. taint( @list ) Marks each (apparently) taintable argument in @list as being tainted. References can be tainted like any other scalar, but it doesn't make sense to, so they will not be tainted by this function. Some "tie"d and magical variables may fail to be tainted by this routine, try as it may.) taint_deeply( @list ) Similar to "taint", except that if any elements in @list are references, it walks deeply into the data structure and marks each taintable argument as being tainted. If any variables are "tie"d this will taint all the scalars within the tied object. AUTHOR
Written by Andy Lester, "<andy@petdance.com>". COPYRIGHT
Copyright 2004, Andy Lester, All Rights Reserved. You may use, modify, and distribute this package under the same terms as Perl itself. perl v5.14.2 2004-08-10 Taint(3pm)
All times are GMT -4. The time now is 09:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy