syntax issue in ksh file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting syntax issue in ksh file
# 1  
Old 10-30-2007
syntax issue in ksh file

Hi all,

I am struck with syntax for long time,
Need to purge some lines from given file
Not able to use value of $x

Example of ksh script...
Facing some syntax issue.
Have Tried ‘with single , double ,backtick “” ` and \ escape character , doesn't seem to work.

<line 1> echo $x # $x substituted by 45 in previous part of ksh file
<line 2> sed -e '1,$(x)d' < $REPORTPATH > REPORT_FINAL # report (temporary input and output files)

For example $x= 45
need to delete first 45 lines .

throws exception of parsing error for the above line 2
if used $x
but without any substitution of $x and use directly 45 instead of $x , works fine.so the problem is with some special character which i aint able o figure out.

sed -e '1,45d' < $REPORTPATH > REPORT_FINAL

let me know what syntax to be followed. To use it for $x
For variable that has been derived its value programmatically.

thnx
# 2  
Old 10-30-2007
Try :
Code:
sed -e "1,${x}d" < $REPORTPATH > REPORT_FINAL # report (temporary input and output files)

Jean-Pierre.
# 3  
Old 10-30-2007
tats great , thanks a lot!!!

some tips to remember syntax!!!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with ksh syntax error Unexpected Fi

Issue resolved, thanks (6 Replies)
Discussion started by: dangell82
6 Replies

2. UNIX for Advanced & Expert Users

Syntax issue in curl for getting a file from http site

Hi All I am using curl in my client environment. We need to pull a file from the libraries site. All the files are having perticular URL which can be used to get the files. Only issue is, when we fire that command , it will take to authentication page 1st. once authentication is succed, it will... (1 Reply)
Discussion started by: prabirkumardhar
1 Replies

3. Shell Programming and Scripting

syntax of if condition in ksh is wrong

The syntax of 'if' conditionals in bash and ksh seems different. I am trying to check for a particular version using 'if' in ksh. This very simple syntax gives syntax error. I have tried many variants, but no go. Please correct the syntax. Later I will expand it to 'if' and 'else'. #!/bin/ksh... (8 Replies)
Discussion started by: nivedhitha
8 Replies

4. Shell Programming and Scripting

KSH syntax error

Hi all, Anyone know why I get the error below under ksh? $ EXCLUDES=( $(< "$EXCLUDES_FILE") ) sh: syntax error: `(' unexpected I'm trying to use the above line in a script and it's not working. The guy that gave me the script was running in a linux environment, so I'm thinking this might... (1 Reply)
Discussion started by: mmw
1 Replies

5. Shell Programming and Scripting

ksh syntax error: `(' unexpected

So I am trying to convert my bash script into ksh, and this is what I have in the file so far: #!/bin/ksh login() { if then sendcmd BETA else sendcmd "$(xxd -c 32 -g 0 ${ZETA_ZETA} | awk '{print $2}')" fi } But when I run it: $ ./test.sh ... (1 Reply)
Discussion started by: guitarscn
1 Replies

6. Shell Programming and Scripting

ksh vs ksh93 -- syntax error ... `(' unmatched.

x=$(cat <<EOF Hi. EOF) print "$x" If my shebang is "/bin/ksh" this print "Hi." If my shebang is /bin/ksh93 this errors with: syntax error at line 3: `(' unmatched. I guess my default ksh is ksh88. So, I'm used to setting variables this way, allowing a complex command (that may... (4 Replies)
Discussion started by: mattmiller
4 Replies

7. Shell Programming and Scripting

KSH - different syntax for function

Hi, I wanted to know what's the difference between the below two syntax used for writing ksh function: e.g. 1 ------ function fn1 { echo "Hello World" } e.g. 2 ------ fn1 () { echo "Hello World" } (4 Replies)
Discussion started by: dips_ag
4 Replies

8. Shell Programming and Scripting

Checking ksh script syntax

To check a bash script syntax without executing it we use: bash -n scriptname What should be the equivalent command for checking a ksh script? (8 Replies)
Discussion started by: proactiveaditya
8 Replies

9. Shell Programming and Scripting

syntax for CAT in ksh

Just want to ask if the below code is correct; if ; then echo "No log found from " $data exit 0 else cat out.txt fi this is to test if the content of out.txt is 0 then message appear that there is no log. Is this correct? (3 Replies)
Discussion started by: harry0013
3 Replies

10. Shell Programming and Scripting

ksh syntax explanation - from mimetool

Hi I got this part of the script from the mimetool by Perderabo. I have difficulty in decyphering the syntax specially lines 4,5 & 9. Also the test condition in line 3. Could someone help me on this please. -------------------------------------- pwentry=$(grep "^$(logname):" /etc/paswd)... (2 Replies)
Discussion started by: chaandana
2 Replies
Login or Register to Ask a Question