Sponsored Content
Top Forums Shell Programming and Scripting Insert a user input string after matched string in file Post 303022525 by RudiC on Sunday 2nd of September 2018 11:51:34 AM
Old 09-02-2018
So - what do you expect? It prints exactly what you told it to print. Did you do a test run with nothing but my proposal, unalterd?

Last edited by RudiC; 09-02-2018 at 04:12 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

String extraction from user input - sh

Hi, I have a shell script to build components of a product. The follow snippet will explain what I am doing. # !/bin/sh for choice in "$@" ; do case $choice in "o") echo "Calling $choice" ; o ;; "i") echo... (8 Replies)
Discussion started by: vino
8 Replies

2. Shell Programming and Scripting

save every line in log file with matched string

i have been doing this script to match every line in a current log file (access_log) with strings that i list from a path (consist of 100 of user's name ex: meggae ).. and then make a directory of every string from the text file (/path/meggae/) --->if it matched.. then print every line from the... (3 Replies)
Discussion started by: meggae
3 Replies

3. Shell Programming and Scripting

Extracting particular string in a file and storing matched string in output file

Hi , I have input file and i want to extract below strings <msisdn xmlns="">0492001956</ msisdn> => numaber inside brackets <resCode>3000</resCode> => 3000 needs to be extracted <resMessage>Request time getBalances_PSM.c(37): d out</resMessage></ns2:getBalancesResponse> => the word... (14 Replies)
Discussion started by: sushmab82
14 Replies

4. Shell Programming and Scripting

input a string and copy lines from a file with that string on it

i have a file1 with many lines. i have a script that will let me input a string. for example, APPLE. what i need to do is to copy all lines from file1 where i can find APPLE or any string that i specify and paste in on file 2 thanks in advance! (4 Replies)
Discussion started by: engr.jay
4 Replies

5. Shell Programming and Scripting

Grep a string from input file and delete next three lines including the line contains string in xml

Hi, 1_strings file contains $ cat 1_strings /home/$USER/Src /home/Valid /home/Review$ cat myxml <projected value="some string" path="/home/$USER/Src"> <input 1/> <estimate value/> <somestring/> </projected> <few more lines > <projected value="some string" path="/home/$USER/check">... (4 Replies)
Discussion started by: greet_sed
4 Replies

6. Shell Programming and Scripting

Matching string from input to string of file

Hi, i want to know how to compare string of file with input string im trying following code: file_no=`paste -s -d "||||\n" a.txt | cut -c 1` #it will return collection number from file echo "enter number" read " curr_no" if ; then echo " current number already present" fi ... (4 Replies)
Discussion started by: a_smith
4 Replies

7. Shell Programming and Scripting

String generation from user input

Hi I have one thing I need advice on, and I don't know where to start so I have no sample code. I want the user to provide input like: 1-3,6,7,9-11 When the input is like this, I want a string to be generated including all the numbers. In the example above, the string would look like: 1... (13 Replies)
Discussion started by: Tobbev
13 Replies

8. UNIX for Dummies Questions & Answers

Commenting a line matched with a specific string in a file

Hi, I would like to comment a line that matched a string "sreenivas" in a file without opening it. Thanks in advance. Regards, Sreenivas (3 Replies)
Discussion started by: raosr020
3 Replies

9. UNIX for Dummies Questions & Answers

Search String, Out matched text and input text for no match.

I need to search a string for some specific text which is no big deal using grep. My problem is when the search fails to find the text. I need to add text like "na" when my search does not match. I have tried this command but it does not work when I put the command in a loop in a bash script: ... (12 Replies)
Discussion started by: jojojmac5
12 Replies

10. Shell Programming and Scripting

Insert String every n lines, resetting line counter at desired string

I need to read a text file and insert a string every n lines, but also have the line counter restart when I come across a header string. Line repeating working every 3 lines using code: sed '0~3 s/$/\nINSERT/g' < INPUT/PATH/FILE_NAME.txt > OUTPUT/PATH/FILE_NAME.txt I cannot seem to find... (1 Reply)
Discussion started by: Skonectthedots
1 Replies
Test::SQL::Translator(3pm)				User Contributed Perl Documentation				Test::SQL::Translator(3pm)

NAME
Test::SQL::Translator - Test::More test functions for the Schema objects. SYNOPSIS
# t/magic.t use FindBin '$Bin'; use Test::More; use Test::SQL::Translator; # Run parse my $sqlt = SQL::Translator->new( parser => "Magic", filename => "$Bin/data/magic/test.magic", ... ); ... my $schema = $sqlt->schema; # Test the table it produced. table_ok( $schema->get_table("Customer"), { name => "Customer", fields => [ { name => "CustomerID", data_type => "INT", size => 12, default_value => undef, is_nullable => 0, is_primary_key => 1, }, { name => "bar", data_type => "VARCHAR", size => 255, is_nullable => 0, }, ], constraints => [ { type => "PRIMARY KEY", fields => "CustomerID", }, ], indices => [ { name => "barindex", fields => ["bar"], }, ], }); DESCSIPTION
Provides a set of Test::More tests for Schema objects. Testing a parsed schema is then as easy as writing a perl data structure describing how you expect the schema to look. Also provides maybe_plan for conditionally running tests based on their dependencies. The data structures given to the test subs don't have to include all the possible values, only the ones you expect to have changed. Any left out will be tested to make sure they are still at their default value. This is a useful check that you your parser hasn't accidentally set schema values you didn't expect it to. For an example of the output run the t/16xml-parser.t test. Tests All the tests take a first arg of the schema object to test, followed by a hash ref describing how you expect that object to look (you only need give the attributes you expect to have changed from the default). The 3rd arg is an optional test name to pre-pend to all the generated test names. table_ok field_ok constraint_ok index_ok view_ok trigger_ok procedure_ok CONDITIONAL TESTS
The "maybe_plan" function handles conditionally running an individual test. It is here to enable running the test suite even when dependencies are missing; not having (for example) GraphViz installed should not keep the test suite from passing. "maybe_plan" takes the number of tests to (maybe) run, and a list of modules on which test execution depends: maybe_plan(180, 'SQL::Translator::Parser::MySQL'); If one of "SQL::Translator::Parser::MySQL"'s dependencies does not exist, then the test will be skipped. EXPORTS
table_ok, field_ok, constraint_ok, index_ok, view_ok, trigger_ok, procedure_ok, maybe_plan TODO
Test the tests! Test Count Constants Constants to give the number of tests each *_ok sub uses. e.g. How many tests does field_ok run? Can then use these to set up the test plan easily. Test skipping As the test subs wrap up lots of tests in one call you can't skip idividual tests only whole sets e.g. a whole table or field. We could add skip_* items to the test hashes to allow per test skips. e.g. skip_is_primary_key => "Need to fix primary key parsing.", yaml test specs Maybe have the test subs also accept yaml for the test hash ref as its a much nicer for writing big data structures. We can then define tests as in input schema file and test yaml file to compare it against. BUGS
AUTHOR
Mark D. Addison <mark.addison@itn.co.uk>, Darren Chamberlain <darren@cpan.org>. Thanks to Ken Y. Clark for the original table and field test code taken from his mysql test. SEE ALSO
perl(1), SQL::Translator, SQL::Translator::Schema, Test::More. perl v5.14.2 2012-01-18 Test::SQL::Translator(3pm)
All times are GMT -4. The time now is 09:26 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy