Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Trying a arithmatic on a command line vs scripting. Post 302338221 by CasperQuiet on Monday 27th of July 2009 09:56:18 AM
Old 07-27-2009
Trying a arithmatic on a command line vs scripting.

Hi Everyone!
I'm trying to do simple math on a single command line instead of a script which I've already set up using let etc. I can not get the same output to display on a command line.

Essentially I would like a=20, b=50, and c=a*b.

When I tried:
let "A=20, B=50"; let C=A*B; echo $C

I got the answer but the following error message:
-bash: let: 1000=A*B; attempted assignment to non-varible (error token is "=A*B")

I didn't know if that meant to add quotes in the formula...so i tried that and it didn't work either. Where am i making the mistake?

Thanks so much!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

KSH arithmatic Integer overflow

Guys, I have two big numbers to multiply. In doing do I am getting integer overflow. I managed to multiply number but this number is useless as KSh does not recognise it as a valid number. Here is what I am doing $ expr 999999999999 \* 100 276447132 I got the right value by doing... (2 Replies)
Discussion started by: vikas_sri
2 Replies

2. Shell Programming and Scripting

End of Line in Shell Scripting

I have a file containing records seperated by delimiter '|'.A record is contained on 2 or 3 lines. Now I need a shell script which could write all records with in two '|' character in one line.....for example..... |R1........................R1 R1..........................R1... (2 Replies)
Discussion started by: 33junaid
2 Replies

3. Shell Programming and Scripting

Unix Arithmatic operation issue , datatype issue

Hi, I have a shell scripting. This will take 7 digit number in each line and add 7 digit number with next subsequent lines ( normal addition ). Eg: 0000001 0000220 0001235 0000022 0000023 ........... ......... ........ Like this i am having around 1500000 records. After adding... (23 Replies)
Discussion started by: thambi
23 Replies

4. Shell Programming and Scripting

arithmatic with awk

hi, i am trying some awk arthmatic calculation,i have a problem if any one can help let say if i have a file exm.txt 3 + 2 3 * 2 3 / 2 3 - 2 the output expected is awk -f exm.awk exm.txt 3 + 2 = 5 3 * 2 = 6 3 / 2 = 1.5 3 - 2 = 1 i simply used exm.awk { print $1 " + " $3 "= " $1 +... (3 Replies)
Discussion started by: phone_book
3 Replies

5. Shell Programming and Scripting

How to compare a command line parameter with -- in shell scripting

Hi, I need to check if a parameter provided at the command line is equal to --.How can i do that ? Please help me. Thanks and Regards, Padmini (4 Replies)
Discussion started by: padmisri
4 Replies

6. Shell Programming and Scripting

awk: round output or delimit output of arithmatic string

I have a file with the following content. > cat /tmp/internetusage.txt 6709.296322 30000 2/7/2010 0.00I am using the following awk command to calculate a percentage from field 1 and 2 from the file. awk '{ print $1/$2*100 }' /tmp/internetusage.txt This outputs the value "22.3643" as a... (1 Reply)
Discussion started by: jelloir
1 Replies

7. Shell Programming and Scripting

Need one line scripting on Unix shell..help!!

Hi Experts, I need one line script for the below requirement. First it should check if a directory with todays date exist, and if not create it and move the PDF file to that directory. thanks in advance!!! (2 Replies)
Discussion started by: eeegopikannan
2 Replies

8. Shell Programming and Scripting

arithmatic

Hi Guys, I am relatively new to scripting at the moment and am struggling to get the following function to work. For some reason it does not recognise the arithmatic symbol when i select option1. Any help would be greatly appreciated. menu () { echo "==============" echo "Calculator"... (4 Replies)
Discussion started by: somersetdan
4 Replies

9. Shell Programming and Scripting

sed command to replace a line at a specific line number with some other line

my requirement is, consider a file output cat output blah sdjfhjkd jsdfhjksdh sdfs 23423 sdfsdf sdf"sdfsdf"sdfsdf"""""dsf hellow there this doesnt look good et cetc etc etcetera i want to replace a line of line number 4 ("this doesnt look good") with some other line ... (3 Replies)
Discussion started by: vivek d r
3 Replies

10. Shell Programming and Scripting

Help with scripting-->Inserting a line before a pattern

Hi Guys, I have written the following script test.sh in Linux . read -p "Please enter the name of the application: " DIRTOCREATE read -p "Please enter the number of associates to be given access to svn:" COUNT for (( i=0 ; i<$COUNT ; i++ )) do read -p "Enter the associate id :"... (2 Replies)
Discussion started by: Pradeep_1990
2 Replies
SCRIPT(1)						    BSD General Commands Manual 						 SCRIPT(1)

NAME
script -- make typescript of terminal session SYNOPSIS
script [-akq] [-t time] [file [command ...]] DESCRIPTION
The script utility makes a typescript of everything printed on your terminal. It is useful for students who need a hardcopy record of an interactive session as proof of an assignment, as the typescript file can be printed out later with lpr(1). If the argument file is given, script saves all dialogue in file. If no file name is given, the typescript is saved in the file typescript. If the argument command is given, script will run the specified command with an optional argument vector instead of an interactive shell. The following options are available: -a Append the output to file or typescript, retaining the prior contents. -k Log keys sent to program as well as output. -q Run in quiet mode, omit the start and stop status messages. -t time Specify time interval between flushing script output file. A value of 0 causes script to flush for every character I/O event. The default interval is 30 seconds. The script ends when the forked shell (or command) exits (a control-D to exit the Bourne shell (sh(1)), and exit, logout or control-D (if ignoreeof is not set) for the C-shell, csh(1)). Certain interactive commands, such as vi(1), create garbage in the typescript file. The script utility works best with commands that do not manipulate the screen. The results are meant to emulate a hardcopy terminal, not an addressable one. ENVIRONMENT
The following environment variable is utilized by script: SHELL If the variable SHELL exists, the shell forked by script will be that shell. If SHELL is not set, the Bourne shell is assumed. (Most shells set this variable automatically). SEE ALSO
csh(1) (for the history mechanism). HISTORY
The script command appeared in 3.0BSD. BUGS
The script utility places everything in the log file, including linefeeds and backspaces. This is not what the naive user expects. It is not possible to specify a command without also naming the script file because of argument parsing compatibility issues. When running in -k mode, echo cancelling is far from ideal. The slave terminal mode is checked for ECHO mode to check when to avoid manual echo logging. This does not work when in a raw mode where the program being run is doing manual echo. BSD
January 22, 2004 BSD
All times are GMT -4. The time now is 11:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy