Sponsored Content
Full Discussion: pass parameter to SED
Top Forums Shell Programming and Scripting pass parameter to SED Post 302712667 by deep_kol on Tuesday 9th of October 2012 01:06:07 PM
Old 10-09-2012
pass parameter to SED

My script(ksh) works fine for
---------------------------------------------------
Code:
sed -n '28,31p' ${l_name} >> ${LOG_DIR}/Email.txt

---------------------------------------------------
But I wand to pass parrmeter to this syntax

I did the following things
---------------------------------------------------
Code:
 grep -n '^bad' ${l_name}|read lstart 
 grep -n '^Statistics' ${l_name}|read lend

---------------------------------------------------

lstart will give me 28 and lend will 31 . Now How I will pass it sed.
below code doesnt work
---------------------------------------------------
Code:
sed -n '$lstart,${lend}p' ${l_name} >> ${LOG_DIR}/Email.txt

---------------------------------------------------
Pease suggest me .

Last edited by Scrutinizer; 10-09-2012 at 02:41 PM.. Reason: code tags
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

PASS parameter to AWK

Hi, Can i pass a parameter(not a file name) as a parameter to a awk program? eg; $awk -f test 1 2 3 here test is the filename...and 1,2,3 are the i/p parameters? thank you:-) (2 Replies)
Discussion started by: unisam
2 Replies

2. Shell Programming and Scripting

Help required to pass the parameter

i am calling a pl/sql procedure through a shell script, there is one IN and 2 OUT parameter required to pass to the procedure to execute.. My procedure is XX_CITIDIRECT_EXP_PKG.main_proc and In parameter is p_period which I wanto to pass 'MAY-06'. Can anyone figure out, whats is wrong here ... (4 Replies)
Discussion started by: u263066
4 Replies

3. Shell Programming and Scripting

Pass parameter into script

I would like to write a scirpt a.sh that it first checks the first parameter of the input. If it fulfill some condition ,then run an executable program b by using all the parameter. ie. > ./a.sh 10 20 30 40 50 Then a.sh first checks the first parameter, 10, if it mathes the requirement, then... (2 Replies)
Discussion started by: alfredo
2 Replies

4. Shell Programming and Scripting

How to pass a parameter

Hi all, How to pass a parameter from a oracle pl/sql procedure parameter to shell environment and use it? (1 Reply)
Discussion started by: megh
1 Replies

5. UNIX for Dummies Questions & Answers

How to pass the parameter value to a... ?

Hello I have a simple code like this one: #!/bin/ksh VER=$1 cat /usr/text | while read line do echo $line done Let's say $1=1.0.0 and the contents of text is: abcd.cfg asdf I would like the output to be like this abcd1.0.0.cfg asdf1.0.0 I am thinking of passing the... (5 Replies)
Discussion started by: khestoi
5 Replies

6. Shell Programming and Scripting

How to pass a parameter from the terminal?

Hi, I am new in Ubuntu, I will be glud to know: 1. How to pass a parameter from the terminal to a file that I write in shell script. What is the command line I need to write in the terminal? 2. How to get the parameter in the file? What do I need to write in the file? 3. What kind of file is... (1 Reply)
Discussion started by: vess
1 Replies

7. Shell Programming and Scripting

Pass value from file to parameter

Hi Guys, I have a file in the format Parmater=value. I want to read the value and pass it to corresponding Variable. The Parameter file is as follows Number=23 Text1=mango Text2=yup 'Number' value needs to be read and passed to ID variable. Also, 'Text1' value needs to be passed to... (9 Replies)
Discussion started by: mac4rfree
9 Replies

8. Shell Programming and Scripting

Pass parameter

Hi, I have following for loop , please let me know how to get ${TXP_EXT_TABLE_${i}_SQL} parameter with 1DAY and 7DAY values. for i in 1DAY 7DAY do ${NZSQL_DIR}/nzsql -h ${HOST} -time -v ON_ERROR_STOP=1 -f ${SQL_DIR}/${TXP_EXT_TABLE_${i}_SQL} > ${TMP_LOG_FILE} 2>&1 done ... (4 Replies)
Discussion started by: sandy162
4 Replies

9. Shell Programming and Scripting

How to pass parameter to bteq?

I am using below code to connect terdata and getting the query result in a file.Now i want to use same code for different tables,plz tell me how to pass table name as parameter.i tried using as below code but not working. bteq < /download/viv/dev/ops/Scripts/ter.sh FLTORGTKR_ORG_etc.. ... (1 Reply)
Discussion started by: katakamvivek
1 Replies
SED(1)                                                             User Commands                                                            SED(1)

NAME
sed - stream editor for filtering and transforming text SYNOPSIS
sed [OPTION]... {script-only-if-no-other-script} [input-file]... DESCRIPTION
Sed is a stream editor. A stream editor is used to perform basic text transformations on an input stream (a file or input from a pipe- line). While in some ways similar to an editor which permits scripted edits (such as ed), sed works by making only one pass over the input(s), and is consequently more efficient. But it is sed's ability to filter text in a pipeline which particularly distinguishes it from other types of editors. -n, --quiet, --silent suppress automatic printing of pattern space -e script, --expression=script add the script to the commands to be executed -f script-file, --file=script-file add the contents of script-file to the commands to be executed --follow-symlinks follow symlinks when processing in place -i[SUFFIX], --in-place[=SUFFIX] edit files in place (makes backup if SUFFIX supplied) -l N, --line-length=N specify the desired line-wrap length for the `l' command --posix disable all GNU extensions. -E, -r, --regexp-extended use extended regular expressions in the script (for portability use POSIX -E). -s, --separate consider files as separate rather than as a single, continuous long stream. --sandbox operate in sandbox mode. -u, --unbuffered load minimal amounts of data from the input files and flush the output buffers more often -z, --null-data separate lines by NUL characters --help display this help and exit --version output version information and exit If no -e, --expression, -f, or --file option is given, then the first non-option argument is taken as the sed script to interpret. All remaining arguments are names of input files; if no input files are specified, then the standard input is read. GNU sed home page: <http://www.gnu.org/software/sed/>. General help using GNU software: <http://www.gnu.org/gethelp/>. E-mail bug reports to: <bug-sed@gnu.org>. COMMAND SYNOPSIS
This is just a brief synopsis of sed commands to serve as a reminder to those who already know sed; other documentation (such as the tex- info document) must be consulted for fuller descriptions. Zero-address ``commands'' : label Label for b and t commands. #comment The comment extends until the next newline (or the end of a -e script fragment). } The closing bracket of a { } block. Zero- or One- address commands = Print the current line number. a text Append text, which has each embedded newline preceded by a backslash. i text Insert text, which has each embedded newline preceded by a backslash. q [exit-code] Immediately quit the sed script without processing any more input, except that if auto-print is not disabled the current pattern space will be printed. The exit code argument is a GNU extension. Q [exit-code] Immediately quit the sed script without processing any more input. This is a GNU extension. r filename Append text read from filename. R filename Append a line read from filename. Each invocation of the command reads a line from the file. This is a GNU extension. Commands which accept address ranges { Begin a block of commands (end with a }). b label Branch to label; if label is omitted, branch to end of script. c text Replace the selected lines with text, which has each embedded newline preceded by a backslash. d Delete pattern space. Start next cycle. D If pattern space contains no newline, start a normal new cycle as if the d command was issued. Otherwise, delete text in the pat- tern space up to the first newline, and restart cycle with the resultant pattern space, without reading a new line of input. h H Copy/append pattern space to hold space. g G Copy/append hold space to pattern space. l List out the current line in a ``visually unambiguous'' form. l width List out the current line in a ``visually unambiguous'' form, breaking it at width characters. This is a GNU extension. n N Read/append the next line of input into the pattern space. p Print the current pattern space. P Print up to the first embedded newline of the current pattern space. s/regexp/replacement/ Attempt to match regexp against the pattern space. If successful, replace that portion matched with replacement. The replacement may contain the special character & to refer to that portion of the pattern space which matched, and the special escapes 1 through 9 to refer to the corresponding matching sub-expressions in the regexp. t label If a s/// has done a successful substitution since the last input line was read and since the last t or T command, then branch to label; if label is omitted, branch to end of script. T label If no s/// has done a successful substitution since the last input line was read and since the last t or T command, then branch to label; if label is omitted, branch to end of script. This is a GNU extension. w filename Write the current pattern space to filename. W filename Write the first line of the current pattern space to filename. This is a GNU extension. x Exchange the contents of the hold and pattern spaces. y/source/dest/ Transliterate the characters in the pattern space which appear in source to the corresponding character in dest. Addresses Sed commands can be given with no addresses, in which case the command will be executed for all input lines; with one address, in which case the command will only be executed for input lines which match that address; or with two addresses, in which case the command will be executed for all input lines which match the inclusive range of lines starting from the first address and continuing to the second address. Three things to note about address ranges: the syntax is addr1,addr2 (i.e., the addresses are separated by a comma); the line which addr1 matched will always be accepted, even if addr2 selects an earlier line; and if addr2 is a regexp, it will not be tested against the line that addr1 matched. After the address (or address-range), and before the command, a ! may be inserted, which specifies that the command shall only be executed if the address (or address-range) does not match. The following address types are supported: number Match only the specified line number (which increments cumulatively across files, unless the -s option is specified on the command line). first~step Match every step'th line starting with line first. For example, ``sed -n 1~2p'' will print all the odd-numbered lines in the input stream, and the address 2~5 will match every fifth line, starting with the second. first can be zero; in this case, sed operates as if it were equal to step. (This is an extension.) $ Match the last line. /regexp/ Match lines matching the regular expression regexp. cregexpc Match lines matching the regular expression regexp. The c may be any character. GNU sed also supports some special 2-address forms: 0,addr2 Start out in "matched first address" state, until addr2 is found. This is similar to 1,addr2, except that if addr2 matches the very first line of input the 0,addr2 form will be at the end of its range, whereas the 1,addr2 form will still be at the beginning of its range. This works only when addr2 is a regular expression. addr1,+N Will match addr1 and the N lines following addr1. addr1,~N Will match addr1 and the lines following addr1 until the next line whose input line number is a multiple of N. REGULAR EXPRESSIONS
POSIX.2 BREs should be supported, but they aren't completely because of performance problems. The sequence in a regular expression matches the newline character, and similarly for a, , and other sequences. The -E option switches to using extended regular expressions instead; the -E option has been supported for years by GNU sed, and is now included in POSIX. BUGS
E-mail bug reports to bug-sed@gnu.org. Also, please include the output of ``sed --version'' in the body of your report if at all possible. AUTHOR
Written by Jay Fenlason, Tom Lord, Ken Pizzini, and Paolo Bonzini. GNU sed home page: <http://www.gnu.org/software/sed/>. General help using GNU software: <http://www.gnu.org/gethelp/>. E-mail bug reports to: <bug-sed@gnu.org>. COPYRIGHT
Copyright (C) 2017 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. SEE ALSO
awk(1), ed(1), grep(1), tr(1), perlre(1), sed.info, any of various books on sed, the sed FAQ (http://sed.sf.net/grabbag/tutorials/sed- faq.txt), http://sed.sf.net/grabbag/. The full documentation for sed is maintained as a Texinfo manual. If the info and sed programs are properly installed at your site, the command info sed should give you access to the complete manual. sed 4.4 February 2017 SED(1)
All times are GMT -4. The time now is 02:50 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy