Pass string to nummerical value in tcsh


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Pass string to nummerical value in tcsh
# 1  
Old 03-12-2012
Pass string to nummerical value in tcsh

I want to compare two values for Value A and ValueB, however, they are strings, so is there a way I could them into numberical value in tcsh

Code:
#! /bin/tcsh

set ValueA     = `awk '{print $6}' out0File`
set ValueB     = `awk '{print $6}' out1File`
set Delta       = `expr $ValueA - $ValueB`

---------- Post updated 03-13-12 at 10:09 AM ---------- Previous update was 03-12-12 at 05:37 PM ----------

put columns to one line and then use
set Delta = awk '{print $10 -$6}' anyfile

Last edited by pludi; 03-12-2012 at 06:57 AM..
# 2  
Old 03-12-2012
What are you really doing with the data? just finding a delta seems odd with two "one-line" files for input.

awk was meant to work with big files or several files all at once. And do simple stats on that data, for example.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Tcsh, using " in a string variable

Hallo, I try to write a tcsh-script which works with ImageMagick. The following command line works perfectly: convert a.tif -pointsize 80 -draw " gravity NorthWest fill black text 0,12 a " b.tif I use the following code in a script (it is a minimal example to show the problem): ... (3 Replies)
Discussion started by: DanielDD
3 Replies

2. Shell Programming and Scripting

How to pass string into sql query?

Hi Gurus, I have a request which needs to pass string into sql. dummy code as below: sqlplus -s user/password@instance << EOF >>output.txt set echo off head off feed off pagesize 0 trimspool on linesize 1000 colsep , select emp_no, emp_name from emp where emp_no in ('a', 'b', 'c'); exit;... (4 Replies)
Discussion started by: ken6503
4 Replies

3. Shell Programming and Scripting

tcsh - understanding difference between "echo string" and "echo string > /dev/stdout"

I came across and unexpected behavior with redirections in tcsh. I know, csh is not best for redirections, but I'd like to understand what is happening here. I have following script (called out_to_streams.csh): #!/bin/tcsh -f echo Redirected to STDOUT > /dev/stdout echo Redirected to... (2 Replies)
Discussion started by: marcink
2 Replies

4. Ubuntu

How to pass string to another PC in LAN

Need to send string from Ubuntu to Windows XP? It contains URL. If not for XP may be somebody knows how send to another Ubuntu PC. (1 Reply)
Discussion started by: Yola
1 Replies

5. UNIX for Dummies Questions & Answers

tcsh - test for character in string for if then

I apologize if this treads already covered ground (which I sure it must have), however I wasn't able to determine what I needed from searches. I'm trying to do detemine if a string represents a file name or not (i.e., is in the form "string.ext" or just "string"), by seeing if there's a period... (2 Replies)
Discussion started by: deepstructure
2 Replies

6. Programming

How to pass int and return string in C?

hi I want to write a function which takes int as input and returns a string like this. char GetString(int iNo) { switch(iNo) { case 0: return "Zero"; break; case 1: return "One"; break; } } void main() { int i; printf("Enter... (1 Reply)
Discussion started by: atharalikhan
1 Replies

7. Shell Programming and Scripting

How to pass string as a parameter in a script

Hi friends. i am newbie to shell scripting. I need to create a script where i will be passing 2 parameters to the script and based on that it should work. For ex: start_proc a 2 or start_proc b 2 start_proc a 2 --- this should bring up 2 processes as i define inside the script. start_proc... (2 Replies)
Discussion started by: friscouser
2 Replies

8. Shell Programming and Scripting

Not able to pass string with spaces in shell

I have to pass a sentence in a file, the specs are as: cat run | sed 's/SRT/'$8'/g' | sed 's/plength/68/g' | sed 's/stcol/'$5'/g' | sed 's/encol/'$6'/g' | sed 's/brdtype/'$1'/g' | sed 's/brdtxt/'$3'/g' | sed 's/demotxt/Total '$2'/g' | sed 's/bantxt/ban_'$7'/g' | sed 's/validcodes/'$4'/g' >... (15 Replies)
Discussion started by: patilrakesh1984
15 Replies

9. Programming

pass char string via system()

hello all i am trying to pass a argument through system function to a shell script. #shell script echo.sh to display the string echo $1 and the c program is. #include<stdlib.h> int main() { const char *str = "hello all"; system("sh echo.sh str"); } the output i... (5 Replies)
Discussion started by: zius_oram
5 Replies

10. Programming

trying to pass a string

hey guys, I have a function that I need to pass something like this to: function(set=a); so the "set=" part is always the same, but I'm getting the "a" part in a for loop. so the calls would be in a loop and would end up doing: function(set=a); function(set=b); function(set=c);... (4 Replies)
Discussion started by: annie
4 Replies
Login or Register to Ask a Question