Sponsored Content
Full Discussion: shell script question
Top Forums Shell Programming and Scripting shell script question Post 302134098 by blowtorch on Tuesday 28th of August 2007 09:53:13 PM
Old 08-28-2007
How about this?
Code:
#!/usr/bin/ksh
final=""
while read line; do
        case $line in
                [0-9]*.*[0-9]*-) final=$final-${line%-*};;
                *) final=$final+$line ;;
        esac
done < /path_to_file_with_numbers
finalsum=$(echo $final | bc)
echo $finalsum

I am not doing much error checking or validation here. The script expects valid numbers.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script question

Hello, i am doing a project for school and i cannot figure out whats wrong with my 2 programs they dont seem to work at all. the first program is called isprime and naturally it checks to see if hte number is prime or not here is my code: #!/usr/bin/bash num=$1 echo you typed if ... (2 Replies)
Discussion started by: jbou1087
2 Replies

2. UNIX for Dummies Questions & Answers

Linux Shell Question: how to print the shell script name ?

Suppose I have a script named "sc.sh" in the script how to print out its name "sc.sh"? (3 Replies)
Discussion started by: meili100
3 Replies

3. Shell Programming and Scripting

Shell Script question

Hello Experts, I am new at this and need some help. I am looking for a delete command that allows me after I grep for the hostname to delete all the lines between two characters. for example I want to delete the first line all the way up to the } character host test019 { hardware ethernet... (10 Replies)
Discussion started by: ryanique
10 Replies

4. Shell Programming and Scripting

shell script question

Hi, The contents of my file is below: Name,Location,Degree,Gender,Awards Robert,Philadelphia,Accounting,Male,5 Jane,Chicago,Business,Female,2 Allan,New York,Engineering,Male,6 Tom,Detroit,Computer Science,Male,10 Nancy,Milwaukee,Engineering,Female,4 I want to add a "ID" in the 1st line... (2 Replies)
Discussion started by: xinoo
2 Replies

5. Shell Programming and Scripting

shell script question

I have script as following.. server_status= some command | grep "Total error: 0" if ; then echo " Server $(hostname) is Down" >>Result fi else echo " Server is OK on $(hostname)" >>Result the if command seems to be not working properly for some... (13 Replies)
Discussion started by: s_linux
13 Replies

6. Homework & Coursework Questions

Question on shell script

Hiiiiiiiiiiiii all, Please i want your help fast, the teacher gave us this assignment can u help me to write it? this is the question: Write a shell script to point all prime numbers from the fibonacci series of integer N? using Red hat Os Thanks all and waiting for ur answers... (1 Reply)
Discussion started by: moonlips
1 Replies

7. Homework & Coursework Questions

question on shell script

hiiiiiiiiiiiii,,I found an error on my following script but couldnt find it!!! Can you please help me as soon as possible?! echo "enter a number " read n i=0 first=0 second=1 result=0 prime="true" echo –n " $first $second " while do result=`expr $first + $second` first=$second... (10 Replies)
Discussion started by: moonlips
10 Replies

8. Homework & Coursework Questions

question in shell script

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Write a Bourne shell script which: • Has one command line argument. • If the command line argument is a... (5 Replies)
Discussion started by: abood1190
5 Replies

9. Shell Programming and Scripting

Shell script question

Hi all, can you plz check whether the below code is correct & some inputs. I need to read the below file and process it. input : /home/ibm/var.txt urgent not urgent not needed. #!/usr/bin/ksh VAR=/home/ibm/var.txt if ] then (7 Replies)
Discussion started by: ramkumar15
7 Replies

10. Shell Programming and Scripting

Shell script question

As per code it is getting matched. not sure why it assigning to cols=0. Any inputs please. Input : passed is shell.sh c tablename. if ; then cols=1 table=$2 else cols=0 table=$1 fi (1 Reply)
Discussion started by: ramkumar15
1 Replies
BIO_f_cipher(3) 						      OpenSSL							   BIO_f_cipher(3)

NAME
BIO_f_cipher, BIO_set_cipher, BIO_get_cipher_status, BIO_get_cipher_ctx - cipher BIO filter SYNOPSIS
#include <openssl/bio.h> #include <openssl/evp.h> BIO_METHOD * BIO_f_cipher(void); void BIO_set_cipher(BIO *b,const EVP_CIPHER *cipher, unsigned char *key, unsigned char *iv, int enc); int BIO_get_cipher_status(BIO *b) int BIO_get_cipher_ctx(BIO *b, EVP_CIPHER_CTX **pctx) DESCRIPTION
BIO_f_cipher() returns the cipher BIO method. This is a filter BIO that encrypts any data written through it, and decrypts any data read from it. It is a BIO wrapper for the cipher routines EVP_CipherInit(), EVP_CipherUpdate() and EVP_CipherFinal(). Cipher BIOs do not support BIO_gets() or BIO_puts(). BIO_flush() on an encryption BIO that is being written through is used to signal that no more data is to be encrypted: this is used to flush and possibly pad the final block through the BIO. BIO_set_cipher() sets the cipher of BIO b to cipher using key key and IV iv. enc should be set to 1 for encryption and zero for decryption. When reading from an encryption BIO the final block is automatically decrypted and checked when EOF is detected. BIO_get_cipher_status() is a BIO_ctrl() macro which can be called to determine whether the decryption operation was successful. BIO_get_cipher_ctx() is a BIO_ctrl() macro which retrieves the internal BIO cipher context. The retrieved context can be used in conjunction with the standard cipher routines to set it up. This is useful when BIO_set_cipher() is not flexible enough for the applications needs. NOTES
When encrypting BIO_flush() must be called to flush the final block through the BIO. If it is not then the final block will fail a subsequent decrypt. When decrypting an error on the final block is signalled by a zero return value from the read operation. A successful decrypt followed by EOF will also return zero for the final read. BIO_get_cipher_status() should be called to determine if the decrypt was successful. As always, if BIO_gets() or BIO_puts() support is needed then it can be achieved by preceding the cipher BIO with a buffering BIO. RETURN VALUES
BIO_f_cipher() returns the cipher BIO method. BIO_set_cipher() does not return a value. BIO_get_cipher_status() returns 1 for a successful decrypt and 0 for failure. BIO_get_cipher_ctx() currently always returns 1. EXAMPLES
TBA SEE ALSO
TBA 50 2013-03-05 BIO_f_cipher(3)
All times are GMT -4. The time now is 12:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy