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
HTML::Mason::Tests(3pm) 				User Contributed Perl Documentation				   HTML::Mason::Tests(3pm)

NAME
HTML::Mason::Tests - Test harness for testing Mason SYNOPSIS
use HTML::Mason::Tests; my $group = HTML::Mason::Tests->new( name => 'name of group', description => 'tests something' ); $group->add_test( name => 'foo', description => 'tests foo', component => <<'EOF' <%args> $foo => 1 </%args> <% $foo %> EOF expect => <<'EOF', 1 EOF ); $group->run; DESCRIPTION
This module is designed to automate as much as possible of the Mason test suite. It does tasks like write component files to disk, call them, compare the actual results to the expected results, and more. In addition, it also is capable of printing out useful information about test failures when run in verbose mode. See the ADDITIONAL RUN MODES section for more information. It also makes sure that any given group of tests provides all the information needed to run them (test names, components and results, etc.). Now you have no excuse for writing new tests (and that goes double for me!). METHODS
new Takes the following parameters: o name (required) The name of the entire group of tests. o description (required) What this group tests. o pre_test_cleanup (optional, default=1) If this is true (the default), the component root and data directory will be deleted both before and after running tests. add_support Takes the following parameters: o path (required) The path that other components will expect this component to be reachable at. All paths are prepended with the group name. So '/bar' as a support component in the 'foo' group's ultimate path would be '/foo/bar'. o component Text of the support component. This parameter must have a value unless the skip_component parameter is true. o skip_component If true, then the test harness will not write a component to disk for this test. add_test Takes the following parameters: o name (required) The name of this test. o description (required) What this test is testing. o component (required) Text of the component. o path (optional) The path that this component should written to. As with support components, this path is prepended with the group's name. If no path is given, it uses call_path, if given, otherwise it uses the name parameter. o call_path (optional) The path that should be used to call the component. If none is given, it will be /<group name>/<test name>. If a value is given, it is still prepended by /<group name>/. o call_args (optional) The arguments that should be passed to the component, in list or hash reference form. If none is given, no arguments are passed. o compiler_params This is a hash reference of parameters to be passed to the Compiler->new method. o interp_params This is a hash reference of parameters to be passed to the Interp->new method. o interp Provide an HTML::Mason::Interp object to be used for the test. o todo If this is given, the test will be treated as a todo test, so it will be expected to fail. This should be a string. One of the following three options is required: o expect The text expected as a result of calling the component. This parameter is _not_ required when running in Create mode. o expect_error A regex that will be matched against the error returned from the component execution. o no_warnings If true, this means that the test expects to run without generating any warnings. If warnings are generated, the test fails. o expect_warnings A regex that will be matched against any warnings output when running the component. o skip_expect This causes the component to be run but its output is ignored. However, if the component execution causes an error this will cause the test to fail. This is used in a few situations where it is necessary to just run a component as part the preparation for another test. run Run the tests in the group. Class methods These methods are provided since some tests may need to know these values. base_path The base path under which the component root and data directory for the tests are created. comp_root Returns the component root directory. data_dir Return the data directory check_output ( actual => $actual_output, expect => $expected_output ) Given the parameters shown above, this method will check to see if the two are equal. If they're not equal, it will print out an error message attempting to highlight the difference. ADDITIONAL RUN MODES
The following additional modes are available for running tests. Verbose mode To turn this on, set the environment variables MASON_VERBOSE or MASON_DEBUG as true or run the tests as 'make test TEST_VERBOSE=1'. In this mode, the "run" method will output information about tests as they are run. If a test fails, then it will also show the cause of the failure. Debug mode To turn this on, set the MASON_DEBUG environment variable to a true value. In this mode, the "run" method will print detailed information of its actions. This mode includes the output printed in VERBOSE mode. No cleanup mode Setting the MASON_NO_CLEANUP environment variable will tell the module to not clean up generated data from running the tests. This includes the components written to disk and the data directory used during testing. This can be useful when debugging. Create mode If the individual tests are run from the command line with the '--create' flag, then instead of checking the output of a component, the test harness will simply output its results. This allows you to cut and paste these results back into the test file (assuming they are correct!). Running and/or skipping selected tests You can run just some of a test file with the '--tests-to-run' flag or the MASON_TESTS_TO_RUN environment variable. Similarly you can skip specific tests with the '--tests-to-skip' flag or the MASON_TESTS_TO_SKIP environment variable. The value of either flag is a comma-separated list of one or more of [test_file_name:](test_number|test_name|*) e.g. perl ./01-syntax.t --tests-to-run=3,5 MASON_TESTS_TO_SKIP=fake_percent,empty_percents perl ./01-syntax.t MASON_TESTS_TO_RUN="misc:autohandler, request:*, interp:private1" make test Subclassing this module You can run tests with your own Tests.pm subclass using the '--tests-class' flag or the MASON_TESTS_CLASS environment variable. The value is a fully qualified package name that will be loaded before each test file is run. e.g. perl ./01-syntax.t --tests-class=HTML::Mason::Tests::MyTests MASON_TESTS_CLASS=HTML::Mason::Tests::MyTests make test For example, if you have created your own lexer subclass and want to make sure that tests still pass with it, create a Tests subclass that overrides the _make_interp method to use your subclass: sub _make_interp { my ($self, %interp_params) = @_; return HTML::Mason::Interp->new ( lexer_class => HTML::Mason::MyLexer, %interp_params ); } SEE ALSO
HTML::Mason perl v5.14.2 2012-02-04 HTML::Mason::Tests(3pm)
All times are GMT -4. The time now is 10:06 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy