Sponsored Content
Top Forums Shell Programming and Scripting How to use a shell variable on sed command? Post 302983769 by RavinderSingh13 on Monday 17th of October 2016 03:41:44 AM
Old 10-17-2016
Hello ade05fr,

Welcome to forums, could you please try following and let me know if this helps you.
Code:
sed -n '/SQL ID\:\ '"${vSQL_ID}"'/!b;:a;/\*\*\*\*\*\*\*\*\*\*\*\*/!{$!{N;ba}};{/*/p}'  Input_file
OR
sed -n "/SQL ID\:\ ${vSQL_ID}/!b;:a;/\*\*\*\*\*\*\*\*\*\*\*\*/!{$!{N;ba}};{/*/p}"  Input_file

As sample(test) Input_file was not provided so couldn't test it.

Thanks,
R. Singh
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need a sed command that uses variable

Hi , Seen some of wonderful posts. Please have look at my problem. I have a text file ketkee.txt , which look like below. GATES := apple mango banana XMLCHECK := red blue green pink My requiement is to find the line that has XMLCHECK in it. and append two variables followed by a space... (2 Replies)
Discussion started by: ketkeep
2 Replies

2. Shell Programming and Scripting

Insert a line including Variable & Carriage Return / sed command as Variable

I want to instert Category:XXXXX into the 2. line something like this should work, but I have somewhere the wrong sytanx. something with the linebreak goes wrong: sed "2i\\${n}Category:$cat\n" Sample: Titel Blahh Blahh abllk sdhsd sjdhf Blahh Blah Blahh Blahh Should look like... (2 Replies)
Discussion started by: lowmaster
2 Replies

3. UNIX for Dummies Questions & Answers

sed insert command and variable expansion/command substitution

I know this script is crummy, but I was just messing around.. how do I get sed's insert command to allow variable expansion to show the filename? #!/bin/bash filename=`echo $0` /usr/bin/sed '/#include/ { i\ the filename is `$filename` }' $1 exit 0 (8 Replies)
Discussion started by: glev2005
8 Replies

4. Shell Programming and Scripting

Not able to store command inside a shell variable, and run the variable

Hi, I am trying to do the following thing var='date' $var Above command substitutes date for and in turn runs the date command and i am getting the todays date value. I am trying to do the same thing as following, but facing some problems, unique_host_pro="sed -e ' /#/d'... (3 Replies)
Discussion started by: gvinayagam
3 Replies

5. Shell Programming and Scripting

sed command to take variable

I have file File1.txt in which i have to replace a text using sed command File1.txt contents EURAMOUNTTOBEREPLACED I have a AIX shell script for replacing the text AMOUNTTOBEREPLACED Contents of the shell script sum=27 sed 's/AMOUNTTOBEREPLACED/"$sum"/g' File1.txt >> temp mv temp... (5 Replies)
Discussion started by: bk_12345
5 Replies

6. Shell Programming and Scripting

sed command with variable

Hi, I want to insert some text in the begning of each line. But issue is the text that i want to insert is stored into one variable. so my command look like constr="`date | awk '{print $3"-"$2"-"$6}'`",MXGBTST1" " sed 's/^/\$constr/g' alert_temp.csv but sed command instead of taking... (3 Replies)
Discussion started by: ranvijaidba
3 Replies

7. Shell Programming and Scripting

Using a variable in sed command

Hi All, Can I use a variable (using this variable as a counter) in sed cmd? something like below sed -n '${COUNT}p' But it's not working. Pls help. Thanks. Regards, Amee export COUNT=1 export COUNTER=`cat ${BINPATH}/$ALLOC_FILE.clean_1 | wc -l | tr -d " "` while ... (3 Replies)
Discussion started by: Amee5
3 Replies

8. Shell Programming and Scripting

sed command not accepting variable in shell script

I am using a shell script in fedora linux. While calling to the shell I am also passing an argument (var1=0.77) like shown below sh gossip.sh var1=0.77 in the shell following command is written (which doesn't work) sed - i -e 's@prob=@prob="$var1";//@g' file.txt Actually i want the... (7 Replies)
Discussion started by: Fakhar Hassan
7 Replies

9. UNIX for Beginners Questions & Answers

Variable in sed command

Hi All, How can i use a variable in a sed command ? I cant seem to get it to work as at present its just printing $i at the start of every line rather than the variable $1. sed -e "s/^/\$i,|/" Any help would be appreciated. (3 Replies)
Discussion started by: mutley2202
3 Replies

10. Shell Programming and Scripting

Using a variable in sed command

Hi All, Please help me with the below problem if then $a=" " fi echo "ABC1abc" | sed 's/a/'$a'/' The required output is : ABC abc But I am getting the below error: sed: -e expression #1, char 4: unterminated `s' command Please help. (6 Replies)
Discussion started by: rahulsk
6 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 01:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy