Need a help in the Shell script which is erroring out


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need a help in the Shell script which is erroring out
# 1  
Old 12-16-2007
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
# 2  
Old 12-16-2007
try the following:

Code:
echo "\047profile: /export/home/unix1/auto.pr\047 >> $xxyy"

# 3  
Old 12-17-2007
the following is not working ..

is there any other way to fix this

Thanks
# 4  
Old 12-17-2007
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
# 5  
Old 12-18-2007
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
# 6  
Old 12-25-2007
any help ?? in this one

Thanks
# 7  
Old 12-25-2007
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
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Shell script newbie- how to generate service log from shell script

Hi, I am totally a newbie to any programming languages and I just started an entry level job in an IT company. One of my recent tasks is to create a script that is able to show the log file of linux service (i.e. ntpd service) lets say, if I run my script ./test.sh, the output should be... (3 Replies)
Discussion started by: xiaogeji
3 Replies

2. Shell Programming and Scripting

How to write config shell script to pass variables in master shell script?

Dear Unix gurus, We have a config shell script file which has 30 variables which needs to be passed to master unix shell script that invokes oracle database sessions. So those 30 variables need to go through the database sessions (They are inputs) via a shell script. one of the variable name... (1 Reply)
Discussion started by: dba1981
1 Replies

3. UNIX for Dummies Questions & Answers

How to write Config shell script to pass variables in master shell script?

Dear Unix gurus, We have a config shell script file which has 30 variables which needs to be passed to master unix shell script that invokes oracle database sessions. So those 30 variables need to go through the database sessions (They are inputs) via a shell script. one of the variable name... (1 Reply)
Discussion started by: dba1981
1 Replies

4. Shell Programming and Scripting

awk problem - erroring out - unexpected token

can anyone help identify where the issue is here? awk 'BEGIN { c="perl -e 'print scalar(localtime("'${EPOCHTIME}'")), "\n"'"; c|getline; close( c ); print $2" "$3" "$4" "$6; }' bash: syntax error near unexpected token `(' can't seem to figure it out. i tried this: awk 'BEGIN {... (5 Replies)
Discussion started by: SkySmart
5 Replies

5. Shell Programming and Scripting

Unable to pass shell script variable to awk command in same shell script

I have a shell script (.sh) and I want to pass a parameter value to the awk command but I am getting exception, please assist. diff=$1$2.diff id=$2 new=new_$diff echo "My id is $1" echo "I want to sync for user account $id" ##awk command I am using is as below cat $diff | awk... (2 Replies)
Discussion started by: Ashunayak
2 Replies

6. Shell Programming and Scripting

Correct shell script to Call One shell script from another shell script

Hi All, I have new for shell scripting. Problem : I have one scrip at serv1 and path of server is /apps/dev/provimage/scripts and script name:extract_ancillary.bat. I need to call this script at server2(my working server) and execute at server2 . Please let me know how to build the... (5 Replies)
Discussion started by: Vineeta Nigam
5 Replies

7. Shell Programming and Scripting

How to use ssh execute other shell script on other host (shell script include nohup)?

i want use ssh on the host01 to execute autoexec.sh on the host02 like following : host01> ssh host02 autoexec.sh autoexec.sh include nohup command like follwing : nohup /home/jack/deletedata.sh & after i execute ssh host02 autoexec.sh one the host01. i can't found deletedata.sh... (1 Reply)
Discussion started by: orablue
1 Replies

8. AIX

mtime command erroring

I am calling this paramters from a controlfile CONTROLFILE="/u01/scripts/admin/filesystem.ctl" SEARCH_PATH="`grep SEARCH_PATH $CONTROLFILE | awk -F: '{print $2}' `" FILE_TYPE="`grep FILE_TYPE $CONTROLFILE | awk -F: '{print $2}' `" DEL_RETENTION_SIZE="`grep DEL_RETENTION_SIZE $CONTROLFILE |... (5 Replies)
Discussion started by: javeedkaleem
5 Replies

9. Shell Programming and Scripting

1 script 8 boxes and it is erroring on 3 of them

am trying to place a script from one hp11-unix box (where it works) onto three others where it won't. I am using csh and in the script I use the lines set F_SYSTEMS=(/dbs01 /dbs02 /dbm01 /dbm02 /ora_home/app/oracle) on this one the three others throw up on pulling the files. there should be... (2 Replies)
Discussion started by: cat55
2 Replies

10. UNIX for Advanced & Expert Users

DISPLAY variable erroring when installing Oracle 10g.

Hi, I'm trying to install Oracle 10g in Solaris 10. As required in the instructions, I set the DISPLAY variable: $ DISPLAY=192.168.150.128:0.0 ; export DISPLAY when run the runInstaller in a terminal, it displays an error related to DISPLAY variable. :( Any ideas?? Thanks. (2 Replies)
Discussion started by: ffpradella
2 Replies
Login or Register to Ask a Question