syntax of c shell


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting syntax of c shell
# 1  
Old 11-10-2008
syntax of c shell

i have this program in bash shell:

#!/bin/bash
array=(20 20 20 20 20)
i=0
j=0
awk '/%/ {print $3}' try.txt|
while (read s)
arr[$i]=$s
i=`expr $i + 1`
echo "$i"
end

how can i convert this into c shell?
# 2  
Old 11-10-2008
Quote:
Originally Posted by npatwardhan
i have this program in bash shell:

#!/bin/bash
array=(20 20 20 20 20)
i=0
j=0
awk '/%/ {print $3}' try.txt|
while (read s)

That's not the way to do it in bash:

Code:
while read s; do

Quote:
arr[$i]=$s
i=`expr $i + 1`

Why are you using an external command for integer arithmetic in bash?

Code:
i=$(( $i + 1 ))

Quote:
echo "$i"
end

how can i convert this into c shell?

Don't.

Csh Programming Considered Harmful
Top Ten Reasons not to use the C shell
C shell problems
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Syntax error C shell

Hello, I have a newbe syntax error but I cant find it syntax error: unexpected end of file #!/bin/csh # pe request #$ -pe mpi_16 32 #### 16 core : 'mpi_16 16' || 24 core : 'mpi_24 24 ' # our Job name #$ -N test2MD #$ -S /bin/sh (1 Reply)
Discussion started by: dulceC
1 Replies

2. Shell Programming and Scripting

Shell scripting syntax error in if then else

I have one bash shell script to execute table refreshment. At the bottom of script, I have one piece of code to check 'ORA-' error from log file, then send email to DBA or application people. But this piece of code didn't work. I tried different ways and also search online to find where is my... (2 Replies)
Discussion started by: duke0001
2 Replies

3. Shell Programming and Scripting

Shell scripting syntax

mydate ="$(date)" what is the use of adding double code and parenthesis in the above code .. can i write the same code as mydate= $date (5 Replies)
Discussion started by: lobsang
5 Replies

4. UNIX for Beginners Questions & Answers

Need help to convert syntax to shell

Hi Folks - I need help converting a piece of code from batch to bash. Here is the code: FOR /f "eol=; tokens=1,2,3,4 delims=, " %%i in (Update_Subvars.txt) do ( ECHO alter database %%i.%%j set variable %%k %%l; ) What it's doing is retrieving the values from this file: ... (2 Replies)
Discussion started by: SIMMS7400
2 Replies

5. Shell Programming and Scripting

Help with if statement syntax in shell script

I want to make the file test condition a variable ($Prmshn in code below). My goal is to use something like the first three unsuccessful if statetments since the 'if #!/bin/ksh test_input() { Prmshn=${1} InFLNm=${2} ifReq="-$Prmshn $InFLNm" #the following three if statments fail: #if ] ;... (10 Replies)
Discussion started by: ms63707
10 Replies

6. Shell Programming and Scripting

syntax error in shell script

I am creating a shell script. In which, I need to get server name and server IP. I used this command in script. servername=`cat /etc/hosts|grep `eval hostname`|awk '{print $2}'` however, when execute script or put set -x to debug, it return: line 13: syntax error at line 13: `|' unexpected... (4 Replies)
Discussion started by: duke0001
4 Replies

7. Shell Programming and Scripting

Shell advanced syntax?

I am not an expert of shell scripting, but I can do some simple things. Now, I read a script written by others and I need some help from the experts of this forum. Please help me to understand what is going on in this cycle: if ; then ] && \ export... (25 Replies)
Discussion started by: alt
25 Replies

8. Shell Programming and Scripting

Help Syntax Shell-Script

Hi Guys, iīve a question ... but itīs a litte bit tricky: iīve a 3 php-scripts which runīs via cron at night. These script reads an xml-file a writes it in an MySQL-DB. I named them (for example here ) Script1 - Script3. The XML-Files i named xml1 - xml3. Now, iīve build a Batch-file,... (10 Replies)
Discussion started by: jackcracker
10 Replies

9. Shell Programming and Scripting

Shell syntax

I'm having simple question here, and what's the different here? What is the "x" for? Thanks! (5 Replies)
Discussion started by: redstone
5 Replies

10. UNIX for Dummies Questions & Answers

Help with a shell syntax

I have a variable named "xyz" Now what will the below snippet mean: if ( ${?xyz} ) then .... endif What does ? signify here. Thanks (12 Replies)
Discussion started by: vibhor_agarwali
12 Replies
Login or Register to Ask a Question