Sponsored Content
Full Discussion: Area of a square
Top Forums UNIX for Dummies Questions & Answers Area of a square Post 302439214 by SnydeMz on Thursday 22nd of July 2010 05:22:40 AM
Old 07-22-2010
Area of a square

I am just starting out with bash scripting. I tried a simple script to find the area of a square and it didnt run.
Code:
#!/bin/bash
#script to find area of a square based on user input

if [ $# -ne 1 ]
then 
   echo " Usage -$0 x "
   echo " where x is the dimension of the square "
   exit 1
   n1=$1

echo " Area of the square is equal to `expr $n1 * $n1` "

I know its supposed to be simple but someone shed light on whats wrong.

Moderator's Comments:
Mod Comment Use code tags please, ty.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

square brackets

I would like to substitute a phrase which contains square brackets. change TO how? Thanks (2 Replies)
Discussion started by: gilead29
2 Replies

2. Shell Programming and Scripting

Math Square Root

Hi I just stumbled on to these forums today, and I relatively new to unix. I am trying to figure out how to find the square root of a number using a shell script. I am using bash and I have searched and searched but cannot figure out square roots. Hopefully someone can point me in the right... (3 Replies)
Discussion started by: davex4285
3 Replies

3. Shell Programming and Scripting

WHy the double square brackets?

One of the senior administrators gave me a shell script to modify and it begins as follows: if ] && ] {more code follows} Why the double square brackets? (10 Replies)
Discussion started by: mojoman
10 Replies

4. UNIX for Dummies Questions & Answers

least-square fit in Gnuplot

Does anyone know how to find the best least square fit in Gnuplot? (6 Replies)
Discussion started by: cosmologist
6 Replies

5. Shell Programming and Scripting

removing square braces from a particular column

Hey Guys, I have a text which has data like this Taaaa AAA BBB SSSS $ yelpi Taaaa mmmm kly Tnnnw $ meta Baaaa Qriek Trieh Mbjsd $ kingsq .... I need to get an output like this MAX AAA TEST BBB RES SSSS YUYT test MED yelpi (0 Replies)
Discussion started by: naveen@
0 Replies

6. Shell Programming and Scripting

Delete text between square brackets and also delete those square brackets using sed or awk

Hi All, I have a text file which looks like this: computer programming systems engineering I want to get rid of these square brackets and also the text that is inside these brackets. So that my final text file looks like this: computer programming systems engineering I am using... (3 Replies)
Discussion started by: shoaibjameel123
3 Replies

7. Shell Programming and Scripting

Square matrix to columns

Hello all, I am quite new in this but I need some help to keep going with my analysis. I am struggling with a short script to read a square matrix and convert it in two collumns. A B C D A 0.00 0.06 0.51 0.03 B 0.06 0.00 0.72 0.48 C 0.51 0.72 0.00 ... (7 Replies)
Discussion started by: EvaAM
7 Replies

8. Shell Programming and Scripting

Problem with occurence of square brackets

Hello all, I have the following problem: $ cat infile this is spam and i need this too this is spam and i need this too $ perl -nwe '$_ =~ /]+ \]+)\]\]*\]? (\+)$/; print "$1 - $2\n";' infile i need this - too i need this - and i need this too I am not sure how many occurences of... (13 Replies)
Discussion started by: zaxxon
13 Replies

9. Shell Programming and Scripting

Calculate root mean square?

Dear friend, I know for a single case, this could be finished quickly with Excel. But if we have hundreds of files, we definitely want to do it with a script or a FORTRAN code. Since I have no knowledge of FORTRAN, I tried to work out a script to do it. The math is very simple. we chose one atom... (4 Replies)
Discussion started by: liuzhencc
4 Replies

10. Shell Programming and Scripting

IF statement with square brackets

Hi All, Hope you all are doing good. Yesterday in my project i came across a scenario which i can not guess why it was working in one region and why it was not in another region. Please find my issue below. I am using AIX version 6.0 of UNIX in my project, in shell scripting i have the... (1 Reply)
Discussion started by: mad man
1 Replies
mkgeo_grid(1rheolef)						    rheolef-6.1 					      mkgeo_grid(1rheolef)

NAME
mkgeo_grid -- build a strutured mesh of a parallelotope, in 1d, 2d or 3d SYNOPSIS
mkgeo_grid options [nx [ny [nz]]] EXAMPLE
The following command build a triangular based 2d 10x10 grid of the unit square: mkgeo_grid -t 10 > square-10.geo geo square-10.geo or in one comand line: mkgeo_grid -t 10 | geo - DESCRIPTION
This command is usefull when testing programs on simple geometries. It avoid the preparation of an input file for a mesh generator. The optional nx, ny and nz arguments are integer that specifies the subdivision in each direction. By default nx=10, ny=nx and nz=ny. The mesh files goes on standard output. The command supports all the possible element types: edges, triangles, rectangles, tetraedra, prisms and hexahedra. ELEMENT TYPE OPTIONS
-e 1d mesh using edges. -t 2d mesh using triangles. -q 2d mesh using quadrangles (rectangles). -T 3d mesh using tetraedra. -P 3d mesh using prisms. -H 3d mesh using hexahedra. THE GEOMETRY
The geometry can be any [a,b] segment, [a,b]x[c,d] rectangle or [a,b]x[c,d]x[f,g] parallelotope. By default a=c=f=0 and b=d=g=1, thus, the unit boxes are considered. For instance, the following command meshes the [-2,2]x[-1.5, 1.5] rectangle: mkgeo_grid -t 10 -a -2 -b 2 -c -1.5 -d 1.5 | geo - -a float -b float -c float -d float -f float -g float BOUNDARY DOMAINS
-sides -nosides The boundary sides are representd by domains: left, right, top, bottom,front and back. -boundary -noboundary This option defines a domain named boundary that groups all sides. By default, both sides and the whole boundary are defined as domains: mkgeo_grid -t 10 > square.geo geo square.geo mkgeo_grid -t 10 -nosides > square.geo geo square.geo mkgeo_grid -t 10 -noboundary > square.geo geo square.geo mkgeo_grid -t 10 -noboundary -nosides > square.geo geo square.geo REGIONS
-region -noregion The whole domain is splitted into two subdomains: east and west, This option is used for testing computations with subdomains (e.g. transmission problem; see the user manual). mkgeo_grid -t 10 -region | geo - CORNERS
-corner -nocorner The corners (four in 2D and eight in 3D) are defined as OD-domains. This could be usefull for some special boundary conditions. mkgeo_grid -t 10 -corner | geo - mkgeo_grid -T 5 -corner | geo - COORDINATE SYSTEM OPTION
Most of rheolef codes are coordinate-system independant. The coordinate system is specified in the geometry file `.geo'. -zr -rz the 2d mesh is axisymmetric: zr (resp. rz) stands when the symmetry is related to the first (resp. second) coordinate. FILE FORMAT OPTION
rheolef-6.1 rheolef-6.1 mkgeo_grid(1rheolef)
All times are GMT -4. The time now is 07:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy