Sponsored Content
Top Forums Shell Programming and Scripting sed: command garbled - when executed with $variables Post 302315087 by Armaan_S on Monday 11th of May 2009 12:43:45 PM
Old 05-11-2009
sed: command garbled - when executed with $variables

I have got a file job_tree.lst , which contains 1 line as below

$ cat job_tree.lst
ABC_D_EQ_XXXXX_YYYY_PRD_UX 05/08/2009 05:47 05/08/2009 05:50 IN 13412850/0

I want to get a child job string 3 characters offset from the parent job string (i.e. ABC_D_EQ_XXXXX_YYYY_PRD_UX 05/08/2009 05:47 05/08/2009 05:50 IN 13412850/0 available in job_tree.lst)
The command I am using in shell script to carry out the above task is as below

grep $parent job_tree.lst | tail -1 |sed -e 's*'${parent_job_rep}'*'' '${child_job_rep}'*'

but it's producing an error “SED command: Command Garbled error”

Pl see the test below what I have done in the command prompt

$ cat job_tree.lst
ABC_D_EQ_XXXXX_YYYY_PRD_UX 05/08/2009 05:47 05/08/2009 05:50 IN 13412850/0

$ echo $parent
ABC_D_EQ_XXXXX_YYYY_PRD_UX

$ echo $child_job_rep
XYZ_D_EQ_XXXXX_YYYY_PRD_UX 05/08/2009 05:47 05/08/2009 05:50 IN 13412850/0

$ echo $parent_job_rep
ABC_D_EQ_XXXXX_YYYY_PRD_UX 05/08/2009 05:47 05/08/2009 05:50 IN 13412850/0

$ grep $parent job_tree.lst | tail -1 |sed -e 's*'${parent_job_rep}'*'' '${child_job_rep}'*'
sed: command garbled: s*ABC_D_EQ_XXXXX_YYYY_PRD_UX

But when I give literals in place of substitution variables , it's working see below

$ grep $parent job_tree.lst | tail -1 |sed -e 's*ABC_D_EQ_XXXXX_YYYY_PRD_UX 05/08/2009 05:47 05/08/2009 05:50 IN 13412850/0* XYZ_D_EQ_XXXXX_YYYY_PRD_UX 05/08/2009 05:47 05/08/2009 05:50 IN 13412850/0*'
XYZ_D_EQ_XXXXX_YYYY_PRD_UX 05/08/2009 05:47 05/08/2009 05:50 IN 13412850/0

Can the experts help?

Thanks
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Garbled Sed w/variables

I'm trying to get a partial file path by passing the part I want removed to sed. Sed gets garbled when I try multiple directories (i.e. because of the extra slash). For example: FULLFILEPATH="usr/local/bin" STRIPDIR="usr" PARTFILEPATH=`echo $FULLFILEPATH | sed s/\${STRIPDIR}//` Gives me... (3 Replies)
Discussion started by: bergerj3
3 Replies

2. Shell Programming and Scripting

sed: command garbled

Im getting this error message when trying to substitute filepaths in a sed search and replace string #!/usr/bin/ksh ORACLE_SID=PH3 ORACLE_ADMIN=/data01/app/oracle/admin/$ORACLE_SID DATAFILE_DIR=/asterisk/oradata/$ORACLE_SID sed -e s/DBNAME/$ORACLE_SID/g < initPH2.ora | sed -e... (1 Reply)
Discussion started by: blakmk
1 Replies

3. Shell Programming and Scripting

sed: command garbled error.....

Dear friends, please give me the solution to the following query. If a file contains multiple tags of same name, then how to get the required string between the tags, in which the string begins with "W/X" i.e., file1.txt contains following text(please note that all the following tags are in... (1 Reply)
Discussion started by: swamymns
1 Replies

4. Shell Programming and Scripting

Sed: command garbled :s/

Hi, I really need some help, I am using a very basic script to proess a text file. This script has been used many times but all of a sudden all on it's own it's stopped working. The line in the script is: sed 's/ //g' $ORGFILE > $NEWFILE and the error is Sed: command garbled :s/ All... (3 Replies)
Discussion started by: heidi.lightfoot
3 Replies

5. Shell Programming and Scripting

sed: command garbled

Hi, I have a file1 as : A=/home/user B=/home/user1 C=/home/user2 D=/home/aacsms E=/home/user1/temp F=/home/user1/area1 and my script as: a=`cat /home/aacsms7/file1 | grep -i e` b=`user2` sed 's/'$a'/"E=/home/'$b'/temp"/g' < file1 > file2 sed: command garbled:... (3 Replies)
Discussion started by: yesmani
3 Replies

6. Shell Programming and Scripting

sed command garbled error

sed: command garbled: s/ri="*"/ri=" what i did is you can see below sed "s/ri=\"*\"/ri=\"$newri\"/" $2 > output how to solve this (2 Replies)
Discussion started by: pasricha.kunal
2 Replies

7. Shell Programming and Scripting

Sed command garbled question

for j in $(cat ${list_B}) do to_replace_2=$(grep $j ${useralias}_2) sed "s/^${j}/${to_replace_2}/p" ${entries} > ${entries}_2 mv ${entries}_2 ${entries} done Hi, I've the above sed command running in a script. Its basically looping through a file and replacing its beginning of line... (8 Replies)
Discussion started by: Jazmania
8 Replies

8. Shell Programming and Scripting

sed: command garbled error

Hi all, Suppose that I want to update the db.password entry in the below properties file, db.username=admin db.password=qhKkBno2U5GEq5k/dnmGPA== //I want this line to be replaced by: "db.password=abc/123/" db.host=server db.port=22 db.sid=database However when... (2 Replies)
Discussion started by: isaacniu
2 Replies

9. Shell Programming and Scripting

sed help - Command garbled

Hi, First post for a noob so please go easy with me :) I have a XML block that is originally like this: <SETNAME>somecrap/THIS</SETNAME> and I would like it be replaced with, in the original file: <SETNAME>THIS</SETNAME> I tried to use: sed... (4 Replies)
Discussion started by: zhuanyi
4 Replies

10. Shell Programming and Scripting

Command garbled when using sed

Hi everyone, Can anyone help me in question below? I want to cron a job to add partition every month but get the error sed: command garbled: s/YYYYMM/ . > echo $YYYYMON_NEW 201304 > echo $YYYYMON_OLD 201208 > echo $YYYY_MM_NEW 2013-05 This is my base script: ALTER TABLE STS.ADMIN ADD... (1 Reply)
Discussion started by: fenocean
1 Replies
pr(1)							      General Commands Manual							     pr(1)

NAME
pr - Writes a file to standard output SYNOPSIS
pr [-adfFmprt] [-e] [character] [number] [-h header] [-i] [character] [gap] [-l lines] [-n] [character] [width] | [-x] [character] [number] [-o offset] [-s] [character] [-w width] [-column] [+page] [file...] The pr command writes file to standard output. If you do not specify file or if file is -, pr reads standard input. STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: pr: XCU5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. OPTIONS
Displays multicolumn output across the page. (This option is meaningful only in combination with the -column option. It modifies -column so that columns are filled across the page in a round robin order.) Doublespaces the output. Expands tabs to byte positions number+1, 2*number+1, 3*number+1, and so on. The default value of number is 8. Tab characters in the input expand to the appropriate number of spa- ces to line up with the next tab setting. If you specify character (any character other than a digit) that character becomes the input tab character. The default value of character is the ASCII tab character. Uses a formfeed character to advance to a new page. (Otherwise, pr issues a sequence of newline characters.) Pauses before beginning the first page if the standard output is a terminal. Uses a formfeed character to advance to a new page. (Otherwise, pr issues a sequence of newline characters.) Does not pause before beginning the first page if the standard output is a terminal. Displays header instead of the file name in the page header. Replaces multiple space charac- ters with tab characters wherever two or more space characters reach positions gap+1, 2*gap+1, 3*gap+1, and so on. The default value of gap is 8. If you specify character (any character other than a digit), that character becomes the output tab character. (The default value of character is the ASCII tab character.) Sets the length of a page to lines lines (the default is 66). If lines is not greater than the sum of the header and trailer, pr suppresses both header and trailer, as if -t were in effect. Combines and writes all files at the same time, with each file in a separate column. (This overrides the -column and -a options). Provides width-digit line numbering (the default value of width is 5). The number occupies the first width positions of each column of normal output (or each line of -m output). If you specify character (any character, other than a digit), that character is added to the line number to separate it from whatever fol- lows. (The default value of character is an ASCII tab character.) Indents each line of output by offset byte positions (the default is 0). This is in addition to output width (see -w). Pauses before beginning each page if the output is directed to a terminal. (pr sounds the bell at the terminal and waits for you to press <Return>.) Does not display diagnostic messages if the system cannot open files. Sep- arates columns by the single character instead of by the appropriate number of spaces (the default for character is an ASCII tab charac- ter). Does not display the 5-line identifying header and the 5-line footer. Stops after the last line of each file without spacing to the end of the page. [Tru64 UNIX] Same as -n. Sets the width of a line to width byte positions. If neither -w or -s are specified, the default is 72. If only -s is specified, the default is 512. Single column output is not truncated. Produces the specified number of col- umns (the default value is 1). The -e and -i options are assumed for multicolumn output. A text column never exceeds the width of the page (see -l). Begins the display at the specified page number (the default value is 1). Note When used with arguments, the -e, -i, -n, -s, and -x options do not permit white space between the option and its associated argu- ment, or between multiple arguments. OPERANDS
The path name of a file to written. If no file is specified, or - (hyphen) is specified, standard input is used. DESCRIPTION
A heading that contains the page number, date, time, and the name of the file separates the output into pages. Unless specified, columns are of equal width and separated by at least one space. Lines that are too long for the page width are short- ened. If the standard output is a terminal, pr does not display any error messages until it has ended. By default, the input is separated into 66-line pages, including the 5-line header and 5-line footer. If standard output is a terminal, diagnostic (error) messages produced during the operation of pr will be deferred and printed after pr has completed processing. EXIT STATUS
The following exit values are returned: All files have been successfully written. An error occurred. EXAMPLES
To print a file with headings and page numbers on the printer, enter: pr prog.c | lpr This inserts a page break in prog.c, starts each page with a heading, and sends the output to the print command. The heading con- sists of the date the file was last modified, the file name, and the page number. To specify a title, enter: pr -h "MAIN PRO- GRAM" prog.c | lpr This prints prog.c with the title MAIN PROGRAM in place of the file name. The modification date and page number are still printed. To print a file in multiple columns, enter: pr -3 word.lst | lpr This prints the file word.lst in three vertical columns. To print several files side-by-side on the paper, enter: pr -m -h "Mem- bers, Visitors" member.lst visitor.lst | lpr This prints the files member.lst and visitor.lst side-by-side with the title Members, Visitors. To modify a file for later use, enter: pr -t -e prog.c > prog.notab.c This replaces tab characters in prog.c with spaces and puts the result in prog.notab.c. Tab positions are at byte positions 9, 17, 25, 33, and so on. The -e tells pr to replace the tab characters; the -t suppresses the page headings. ENVIRONMENT VARIABLES
The following environment variables affect the execution of pr: Provides a default value for the internationalization variables that are unset or null. If LANG is unset or null, the corresponding value from the default locale is used. If any of the internationalization vari- ables contain an invalid setting, the utility behaves as if none of the variables had been defined. If set to a non-empty string value, overrides the values of all the other internationalization variables. Determines the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multibyte characters in arguments). Determines the locale for the for- mat and contents of diagnostic messages written to standard error. Determines the format of the date and time used in writing header lines. Determines the location of message catalogues for the processing of LC_MESSAGES. FILES
Your terminal, used when the -p option is specified. SEE ALSO
Commands: cat(1), expand(1), mesg(1) Standards: standards(5) pr(1)
All times are GMT -4. The time now is 07:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy