The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
To call/execute a shell script from a shell script konark UNIX for Dummies Questions & Answers 1 10-26-2007 02:16 PM
How to pass a parameter from one Shell-script to another Shell-script subodhbansal Shell Programming and Scripting 2 09-22-2007 02:19 AM
How to Run a shell script from Perl script in Parent shell? hifake Shell Programming and Scripting 16 08-28-2007 05:42 PM
Accessing variables of one shell script in another shell script rsendhilmani Shell Programming and Scripting 1 04-30-2007 05:43 AM
Have a shell script call another shell script and exit heprox Shell Programming and Scripting 2 11-20-2006 05:17 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 12-16-2007
Registered User
 

Join Date: May 2006
Posts: 63
Need a help in the Shell script which is erroring out

Hi all

I want to add this line after a line

This is the line which needs to be add after the word permission

echo 'profile: /export/home/unix1/auto.pr' >> $xxyy

if [ "$value" = "add" ];then
cd $unixserv/unix
sed '
/permission/ a\
echo 'profile: /export/home/unix1/auto.pr' >> $xxyy
generate_autosys_job.ksh > man5.txt

Can you please let me know what is the error

Its not adding the line as it is :echo 'profile: /export/home/unix1/auto.pr' >> $xxyy

Thanks
Reply With Quote
Forum Sponsor
  #2  
Old 12-16-2007
Moderator
 

Join Date: Dec 2003
Location: /dev/fl
Posts: 1,061
try the following:

Code:
echo "\047profile: /export/home/unix1/auto.pr\047 >> $xxyy"
Reply With Quote
  #3  
Old 12-17-2007
Registered User
 

Join Date: May 2006
Posts: 63
the following is not working ..

is there any other way to fix this

Thanks
Reply With Quote
  #4  
Old 12-17-2007
Moderator
 

Join Date: Feb 2007
Posts: 2,329
To output text within single quotes you can place the text within: single quote, double quote, single quote:

Code:
echo '"'profile: /export/home/unix1/auto.pr'"' >> $xxyy
Regards
Reply With Quote
  #5  
Old 12-18-2007
Registered User
 

Join Date: May 2006
Posts: 63
Thanks Guys , But its not working , can you please help m once again ??


This is the code, not able to add the line
echo 'profile: /export/home/'$value'/auto.profile-45' >> $job_name_main'

sed'
/permission/ a\
echo '"'profile: /export/home/'$value'/auto.profile-45'"' >> $job_name_main'

Thanks
Reply With Quote
  #6  
Old 12-25-2007
Registered User
 

Join Date: May 2006
Posts: 63
any help ?? in this one

Thanks
Reply With Quote
  #7  
Old 12-25-2007
drl's Avatar
drl drl is offline
Registered User
 

Join Date: Apr 2007
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 556
Hi.

One method is to use double quotes to allow the single quotes to be treated as normal characters. However, because shell variables are expanded within double quotes, the "$" needs to be escaped:
Code:
#!/usr/bin/env sh

# @(#) s1       Demonstrate insert of line with single quotes and variable.

set -o nounset
echo

debug=":"
debug="echo"

## Use local command version for the commands in this demonstration.

echo "(Versions displayed with local utility \"version\")"
version >/dev/null 2>&1 && version bash sed

echo

FILE=${1-data1}
echo " Input file $FILE:"
cat $FILE

echo
echo " Results from sed:"

sed "
/permission/ a\
echo 'profile: /export/home/unix1/auto.pr' >> \$xxyy
" $FILE

exit 0
Producing:
Code:
% ./s1

(Versions displayed with local utility "version")
GNU bash 2.05b.0
GNU sed version 4.1.2

 Input file data1:
This is a line
Another line
This line contains permission.
This is the line that should appear after the inserted line.
Last line.

 Results from sed:
This is a line
Another line
This line contains permission.
echo 'profile: /export/home/unix1/auto.pr' >> $xxyy
This is the line that should appear after the inserted line.
Last line.
Best wishes ... cheers, drl
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 07:20 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0