embarrassing question: is sh = bash ?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting embarrassing question: is sh = bash ?
# 1  
Old 01-24-2010
embarrassing question: is sh = bash ?

I would like to know the version of my shell. I usually type "sh scriptName".

I googled for it and they usually say bash --version.
But is the same shell ? Can I have installed multiple shells ?

thanks
# 2  
Old 01-24-2010
# 3  
Old 01-24-2010
ok thanks, I have now better question...

i have a small problem in scanning an array in a for loop.

I know how to access to a single cell: $magnaPlaza[$1];

but how can I write the indexing variable in a for loop ?

Code:
for j in `seq 3`
do
echo referenceImage $magnaPlaza[$j];    --> this doesn't work

echo referenceImage $magnaPlaza[$$j];    --> this doesn't work

I need somehow to pass the value of j but keep the $ symbol in front of it...

thanks

Last edited by DukeNuke2; 01-24-2010 at 07:29 AM..
# 4  
Old 01-24-2010
The way to access an element in an array:
Code:
echo "${magnaPlaza[$j]}"

# 5  
Old 01-24-2010
thanks.. however, your line gives me the following error:

scriptAlign: 26: Bad substitution

thanks
# 6  
Old 01-24-2010
How do you assign the values to the array and how does your loop look like?

Post a snippet of your script.
# 7  
Old 01-24-2010
nevermind, I found another solution:

Quote:
eval magnaPlaza1="67"
eval magnaPlaza2="69"
eval magnaPlaza3="75"

eval echo "refImage \$magnaPlaza$ref"
thanks anyway
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash Looking into files question

I have a bunch of files that are messages in my directory. Each message has a date located in the file. How can I look into each file and find the date? Thank you for any help (7 Replies)
Discussion started by: totoro125
7 Replies

2. Programming

Question regarding Bash program

Hello All, I am trying to write a small bash script to make my life easier for an analysis. I have multiple folders and inside them are 10 output files with an extension .pdbqt What I am trying to do is to read the folder content and then make a PyMol (.pml) file to load the molecules and then... (11 Replies)
Discussion started by: biochemist
11 Replies

3. Red Hat

bash profile question

Hello, I'm new to RHEL and I was wondering where the prompt setup is from? This what it looks like: # I like this setup but I would like to add some color to it. I looked in the .profile, .bash_profile and .bashrc. I don't see anything in these files that give me the above prompt. So I looked... (2 Replies)
Discussion started by: bitlord
2 Replies

4. Shell Programming and Scripting

Quick Bash question.

Hi, I'm basically looking to see what this line of code does: . `dirname $0`/../config/config Thanks. (1 Reply)
Discussion started by: cabaiste
1 Replies

5. Shell Programming and Scripting

Nested if question BASH

Just started learning bash ,and I am confused with sintaksis line 16: syntax error near unexpected token `else' thanks #!/bin/bash echo -n "Enter: " read num if(($(echo ${#num}) == 0 )) then echo No arguments passed.Try again elif rem=$(echo $num | tr -d ) ... (7 Replies)
Discussion started by: lio123
7 Replies

6. Shell Programming and Scripting

Yet another bash arrays question

Hi all, I have a file that contains many lines, but only a few are of my interest, so I'm cutting it with grep + awk, and the result I get is for example line 0 line 1 line 2 line 3 line n Now I want to store each line in an array "cell" so I can use it later calling to ${array},... (2 Replies)
Discussion started by: TuxSax
2 Replies

7. UNIX for Dummies Questions & Answers

BASH Pipe question

Hi all, I'm new to shell scripting, but enjoying myself! :cool: I'm trying to execute the following statement: alias evol="ps -AH | grep evol | cut -d' ' -f2 | kill -9" As you might guess. I'm wanting to use a single command 'evol' to kill all the processes containing the phrase 'evol' ... (4 Replies)
Discussion started by: mgrahamnz
4 Replies

8. Shell Programming and Scripting

bash script question

Can anybody be kind to explaing me what the lines below mean ? eval line=$line export $line ] || echo $line (2 Replies)
Discussion started by: jville
2 Replies

9. Shell Programming and Scripting

BASH script question

Hi, I want to create a script that gets a filename as an argument. The script should generate a listing in long list format of the current directory, sorted by file size. This list must be written to a new file by the filename given on the command line. Can someone help me with this? ... (6 Replies)
Discussion started by: I-1
6 Replies

10. Shell Programming and Scripting

bash question

Hi Guys, I found this script for monitoring the status of a services: for i in syslogd cron; do if && ; then printf "%-8s" "$i";printf " is alive=A\n" else printf "%-8s" "$i";printf " is not alive\n" fi The script is working fine except if either syslogd or cron will have a defunct... (3 Replies)
Discussion started by: itik
3 Replies
Login or Register to Ask a Question