Programming :: Random Float Numbers In BASH
Mar 27, 2011
I'm learning shell scripting using bash and I want to generate 4 floating point number with 5 decimal places and write them to a file and a variable. I've done all this except the $RAMDOM enviroment variable does not generate a float number but a integrer.
[code]...
View 4 Replies
ADVERTISEMENT
Feb 2, 2010
For eg: $NUMBEROFPASSES=6.19 to round up I use NUMBEROFPASSES=$(printf %.0f $NUMBEROFPASSES) What I need to do is round up from eg: 6.10 to be 7 and if lower than 6.10 round down to 6
View 5 Replies
View Related
May 25, 2010
I have lines in some files that look exactly as below, and the line numbers they occur in are always the same. (Lines 136-139)
W 0.00000000 0.00000000 2.00000000
W 0.50000000 0.50000000 2.50000000
W 0.00000000 0.00000000 3.00000000
[code]...
View 1 Replies
View Related
Oct 21, 2010
I have a directory with files like this:
Code:
And what I'd like is to have the files renamed like this:
Code:
How could I code it so that it removes the numerical part of the filename (at the beginning), even with different patterns (like the 01 - artist vs the 01-artist)?
View 8 Replies
View Related
Apr 28, 2010
I just need to perform a simple operation of subtracting two numbers - that aren't whole numbers, i.e 200.56 - 67.24attempting to use expr i merely get "expr: non-numeric argument"
View 3 Replies
View Related
May 12, 2011
I tried googling around but i cant find anything related to this: everyone seems just interested in random numbers, so when it comes to random letters there is a lack of informations. However, i am trying to figure out a wait to get a random letters string that matches a simple rule: it must be a sequence of consonant+vowel. So for example, these are some 6 letters strings i would like to obtain: wolupa, tafoke, zewevu, cupimo.
View 3 Replies
View Related
May 25, 2010
How to create random numbers between -5.0 to +5.0
View 12 Replies
View Related
Nov 4, 2010
How can i print the biggest float and biggest double exponential notation in Java ?
View 1 Replies
View Related
Apr 4, 2011
am writing a small search program for my class. I have decided to use indexing for my program. Ive researched online about indexing and how search engines do it. If im gonno do that I need to create inverted files to associate files to numbers ( numbers being the index of my paths ) . Now I was wondering what would be the best way to create an inverted file ? I was going to create sql tables using mysql api in C but then again there is no array data type or vectors to store few numbers in a single column in mysql and it is not advised to use Enum or SET
View 14 Replies
View Related
Jan 13, 2011
I have searched and searched and maybe I don't know how to articulate this issue with out just posting the problem I'm having. Every time I bring up a terminal window I get the following "Header"
declare -x COLORTERM="gnome-terminal"
declare -x CPLUS_INCLUDE_PATH="/usr/lib64/qt/include"
declare -x DBUS_SESSION_BUS_ADDRESS="unix:abstract=/tmp/dbus-xSFd6zqrYQ,guid=dc5e07974559da016842742900000090"
declare -x DISPLAY=":0.0"
[Code]...
To be honest I cheated and used the .bashrc / .profile files from Ubuntu and all was working fine for a while now and it seems something changed to cause this... any ideas on why I am getting this? I checked my .bashrc and my /etc/profile and it doesn't look like anything is amiss..
View 3 Replies
View Related
Nov 16, 2010
Our assignment is to take in two numbers and add them. While the inputs will always be numbers, we are to inform the user if they are doing it wrong. My code:
[Code]....
The code worked fine before I tried to idiot-proof it. I'll probably end up nesting the if statements checking if the first two inputs are not null, but I'm more annoyed at why the script isn't working.
View 3 Replies
View Related
Mar 18, 2011
I'm making an bash script.
As input you can input different numbers from 1 to 3.
Depending from the input a text shows up.
View 2 Replies
View Related
Sep 28, 2009
as a result of a find command, i have
852065 72: /bin/gunzip
852065 72: /bin/gzip
852065 72: /bin/zcat
(the first column is inode number and the second is size if you're curious)
I want to be able to format it in a way such that:
852065 72:
/bin/gunzip
/bin/gzip
/bin/zcat
I know I can get the bottom half using awk- but I can't figure out how to extract the first set of numbers and get them to appear only once
View 9 Replies
View Related
Nov 4, 2010
I have to read a couple of numbers from a random.txt file. In this .txt file there are random numbers. They are separated by a space. Example if you opened test.txt:
test.txt :1 6 1 3 6 8 10 2 4
I would like to read those numbers using CAT and store them into an array:
numlen=${#num[*]} - (must be like this because it is a part of a larger program)
View 5 Replies
View Related
Feb 1, 2010
I have some code that opens a directory and reads in the names of files which are e.g. 0001, 0002, 0003 up to 9999I need to get all these numbers and then generate a new number that is not one of these numbers already.here is my code to check the files in the directory
DIR *d;
struct dirent *dir;
int i = 0;
[code]....
View 11 Replies
View Related
Feb 11, 2010
write a script in bash or shell to add the numbers between and including two numbers
View 3 Replies
View Related
Apr 1, 2010
As some of you know that I am new to this forum. I have another problem that I got stuck on. I have this file called "Fib.rbb" and my instructor told us to write an interpreter program by using Fib.rbb.
"You are to write an interpreter in Perl for Rongs Basic Basic (RBB) as explained in class. The BNF description for RBB and a test file called Fib.rbb are part of the RBB.zip file which is available in the Course Documents folder on blackboard. If you call your interpreter myIntp.pl, you would execute the program via perl myIntp.pl Fib.rbb
Code: Print "A few Fibonacci numbers:"
View 3 Replies
View Related
Mar 28, 2011
Looking for code to add 5 numbers in assembly? I want to use array for input of those 5 numbers. No problem if the output is 1 digit(0....9).
View 3 Replies
View Related
Dec 22, 2010
I am trying to extract 2 numbers from a same file and my goal is to print them both in another file, on the same line, separated with a space. I have to do that for 20 files and I would like to have therefore 20 lines like this in the output file. It would look like this :
Quote:
number1_file1 number2_file1
number1_file2 number2_file2
...
...
number_1_file20 number2_file20
So far, I did only extract one number and got an output file like this :
Quote:
number1_file1
number1_file2
...
...
number1_file20
And I did this by running a bash script with the following content :
Code:
#!/bin/bash
ls execution$1$2*.* | while read filename
do
cat $filename | grep -e "Total aborts:" | cut -d " " -f3 >> abort$1$2.dat
done
$1 and $2 are just strings to identify the different files I want to consider in this loop. This script works well to extract a number which is the 3rd field of a line starting with "Total aborts:".Now, how could I change this script to do what I mentioned above (i.e. extracting two numbers from two different lines) ? The second number is the 3rd field of a line starting with "Total throughput:"
View 7 Replies
View Related
Nov 15, 2010
I want the get the date of the oldest log in this directory and compare it with current date.Time of the each log can be seen before ".Z" prefix.I have written the following piece of code. However, it is not working for the following case:
LOGDAY=20101129
TODAY= 20101201
Difference is 72, which is not correct, since these are dates.
View 11 Replies
View Related
Mar 9, 2011
I'm trying to write a program that generates a random number and then tells if it is prime or not. I have doe some research about how to calculate prime and random numbers but I'm still having trouble. I don't really get how to calculate a prime number. I know a prime number is a number that is divisible by 1 and and itself. how to calculate a prime number in C?
View 10 Replies
View Related
May 11, 2011
I am struggling to understand why nawk matches values that are either 1 or 2 digits in length, but not 100 (3 digits).
Am I missing something obvious ? Should I use substr to remove the % ?
I am sure it's something to do with character and string matching behaviour with nawk.
Code:
View 9 Replies
View Related
Dec 15, 2010
I have a program that sends QByteArray datagrams over a udp socket. I would like to have 4 bytes of the datagram that contain a 32 bit integer. When saving numbers to the QByteArray, I have tried the static function number(int) and member function setNum(int), but they convert the integer to its decimal string representation and save that in the byte array. So if the number were 10, it takes 2 bytes, if it were 10,000,000 it takes 8 bytes. This wastes space, and makes it more difficult to get the number when it is packed with a few other pieces of data in the same datagram. Is there a standard way of doing this in Qt?
View 1 Replies
View Related
Jan 26, 2011
I'm playing around with some shell scripting and I've got a directory call CS005 and I'm trying to write a script to I can locate to the directory really quick and easy.
export CS005DIR=/home/stud/0/043234/CS005
Now I get this error
CS005DIR=/home/stud/0/043234/CS005 No such file or directory.
This is because I've got numerical values within my variable.
Is there a way to allow numbers for variable names?
View 3 Replies
View Related
Dec 30, 2010
If I do:
for i in $(cat names); do seq -f "$i%03.0f" 0 999; done > output5.txt
I got ( tail snipped):
997munt
998munt
999munt
If I do:
for i in $(cat names); do seq -f "%03.0f$i" 0 999; done > output4.txt
I got:
997Zygmunt
998Zygmunt
999Zygmunt
How I can get numbers from 000 to 999 appended like:
Zygmunt997
Zygmunt998
Zygmunt999
View 8 Replies
View Related
Mar 19, 2010
I would like to create a small C tool. I encounter a problem of how to make a function to check an input chars contains numbers (started from the second element).
Some samples:
char *mychar= "a3547"; (The result of function checking this is true)
char *another_char = "t6548"; (The result of function checking this is true)
char *next_char = "appl3"; (The result of function checking this is false)
char *new_char = "b1aa3"; (The result of function checking this is false)
View 4 Replies
View Related
Mar 19, 2011
I am trying to generate sequence of number in the order of :
1
2
3
4
[Code]....
View 7 Replies
View Related
Nov 20, 2010
I have a text file with 4 columns and 18 rows. All are integers. I wish to find the average of first 12 numbers in the third column using 'awk'.
View 8 Replies
View Related
Aug 13, 2010
I'm learning c but then when i tried looping as i follow a tutorial, the numbers are wierd that it seems not right..
This is the example.
Quote:
When i run it, it outputs this.
Quote:
why?
View 2 Replies
View Related
Jan 26, 2011
Can sed remove non-numerics (apart from an optional leading +) from phone numbers when prefixed with text that must be retained? The need is to make phone numbers exported from an Orage address book to a .ldif file suitable for gnokii to send to a mobile phone. Here are sample lines:
Code:
facsimiletelephonenumber: +91 (123) 1234567
telephoneNumber: +44 (123) 1234567
They have to end up as:
Code:
facsimiletelephonenumber: +911231234567
telephoneNumber: +441231234567
I could do it in awk but am curious to learn if sed can do it.
View 11 Replies
View Related