Sponsored Content
Top Forums Shell Programming and Scripting sed not outputing variable into new file Post 302795037 by springs2 on Wednesday 17th of April 2013 06:12:12 AM
Old 04-17-2013
So my initial script has a case command in which calls up functions according to which option i select. Within one of those functions i have the sed code which is to take the input of $SHOW and apply it into the file.

so say $SHOW = test foobar
then the sed command should should run like:
Code:
sed "36a\mv -v $foo/"test foobar"\ $bar/test foobar/" test2.sh > test3.sh

So in tesh3.sh i should see around line 36 the following:
Code:
mv -v $foo/"test foobar"\ $bar/test foobar/

but i always get $SHOW appear in the final file and it never takes the input from $SHOW and replaces it. $foo and $ bar are part of the test3.sh script so all they need to do is be entered into the test3.sh file.

Other parts of the function works when $SHOW is called its just sed that doesn't like the input.

Hope that helps.

Last edited by Franklin52; 04-17-2013 at 08:13 AM.. Reason: Please use code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

outputing sed to a variable

Hello, My appologies for asking a very basic question but... In a shell, I enter: echo tit | sed -e s/tit/tat/g This returns: tat as expected. But when I enter: set test = `echo tit | sed -e s/tit/tat/g` echo $test This returns an empty line. Why is this so and how... (3 Replies)
Discussion started by: flewis
3 Replies

2. Shell Programming and Scripting

sed -i '7 c\$variable' file ....(?!@#$%^&*!)

I have tried everything I can think of to get sed to change line N of a file to the contents of a variable. I have Googled the Internet, and I find lots of people telling how to use variables with the "Substitute" command, but no one telling how to use variables with the "Change" command. I... (4 Replies)
Discussion started by: Mr.Lauren
4 Replies

3. Shell Programming and Scripting

Having sed to read lines of a file with the use of a variable..Possible?

This i will print the second line of a file sed -n '2p' test2 The use of a variable is impossible here. a=1 while ; do line=`sed -n '$a p' test2` # do some things here with the line variable a=`expr $a + 1` done But the uotput of sed command is 'p'..... What can i do to use a variable... (2 Replies)
Discussion started by: hakermania
2 Replies

4. Shell Programming and Scripting

using file-and-replace sed command with the use of a variable?

Ok, so, let's say I have the variable $GMAILID....How can I use it with sed command so to replace a string in a file? e.g.: sed -i 's/$GMAILID/test@gmail.com/' /home/$USER/Desktop/sendmail (4 Replies)
Discussion started by: hakermania
4 Replies

5. Red Hat

How to pass value of pwd as variable in SED to replace variable in a script file

Hi all, Hereby wish to have your advise for below: Main concept is I intend to get current directory of my script file. This script file will be copied to /etc/init.d. A string in this copy will be replaced with current directory value. Below is original script file: ... (6 Replies)
Discussion started by: cielle
6 Replies

6. Shell Programming and Scripting

How to replace a string with a variable in a file using sed?

I have a file having some text like: PATH_ABC=/user/myLocation I have to replace "/user/myLocation" with a session variable say, $REPLACE_PATH, where $REPLACE_PATH=/user/myReplaceLocation The following sed command is not working. It is writing PATH_ABC=$REPLACE_PATH in the file ... (2 Replies)
Discussion started by: SKhan
2 Replies

7. Shell Programming and Scripting

sed replacement in file when line is in a variable

Hi, I have a file where I want to replace the 15th field separated by comma, only on specific lines matching lots of different conditions. I have managed to read the file line by line, within the loop my line is held in a variable called $line I assume this will be using sed (maybe... (5 Replies)
Discussion started by: jpt123
5 Replies

8. Shell Programming and Scripting

sed and variable as target file

for file in `ls /tmp/*_sw_list`; do /usr/bin/sed -i '' '1,/^Software\ Update/d' $file done In my script, this doesn't work. I can copy-and-paste it, and it works. Enabling debugging shows it is resolving the file name correctly... it isn't an issue with special characters in the filename. ... (3 Replies)
Discussion started by: jnojr
3 Replies

9. Shell Programming and Scripting

Using echo, grep and wc and outputing to text file

My current line command is as follows: echo -n "text: " ; grep "blah text" ../dir1/filename | wc -l The output to the screen is as needed, but how do I print to a text file? (9 Replies)
Discussion started by: ncwxpanther
9 Replies

10. UNIX for Beginners Questions & Answers

Awk/sed to replace variable in file

Hi All I have one file with multiple lines in it, each line has static text and some variable enclosed in <<filename>> as well. e.g. as below 123, <<file1.txt>> this is my name, I stay at <<city.txt>> Thanks for visiting 348384y, this is my name <<fileabc.txt>>, I stay at near the mall of... (8 Replies)
Discussion started by: reldb
8 Replies
XML::LibXML::PI(3)					User Contributed Perl Documentation					XML::LibXML::PI(3)

NAME
XML::LibXML::PI - XML::LibXML Processing Instructions SYNOPSIS
use XML::LibXML; # Only methods specific to Processing Instruction nodes are listed here, # see XML::LibXML::Node manpage for other methods $pinode->setData( $data_string ); $pinode->setData( name=>string_value [...] ); DESCRIPTION
Processing instructions are implemented with XML::LibXML with read and write access. The PI data is the PI without the PI target (as specified in XML 1.0 [17]) as a string. This string can be accessed with getData as implemented in XML::LibXML::Node. The write access is aware about the fact, that many processing instructions have attribute like data. Therefore setData() provides besides the DOM spec conform Interface to pass a set of named parameter. So the code segment my $pi = $dom->createProcessingInstruction("abc"); $pi->setData(foo=>'bar', foobar=>'foobar'); $dom->appendChild( $pi ); will result the following PI in the DOM: <?abc foo="bar" foobar="foobar"?> Which is how it is specified in the DOM specification. This three step interface creates temporary a node in perl space. This can be avoided while using the insertProcessingInstruction() method. Instead of the three calls described above, the call $dom->insertProcessingInstruction("abc",'foo="bar" foobar="foobar"'); will have the same result as above. XML::LibXML::PI's implementation of setData() documented below differs a bit from the the standard version as available in XML::LibXML::Node: setData $pinode->setData( $data_string ); $pinode->setData( name=>string_value [...] ); This method allows to change the content data of a PI. Additionally to the interface specified for DOM Level2, the method provides a named parameter interface to set the data. This parameter list is converted into a string before it is appended to the PI. AUTHORS
Matt Sergeant, Christian Glahn, Petr Pajas VERSION
2.0008 COPYRIGHT
2001-2007, AxKit.com Ltd. 2002-2006, Christian Glahn. 2006-2009, Petr Pajas. perl v5.16.2 2012-10-22 XML::LibXML::PI(3)
All times are GMT -4. The time now is 10:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy