General :: If ... Elseif ... Else BASH Ladder - Take In Two Numbers And Add Them
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
ADVERTISEMENT
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
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
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
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
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
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
Aug 10, 2010
Can anyone specify the methods how to add decimal numbers in Linux
View 5 Replies
View Related
Mar 2, 2011
On my board there is no i2c lines out. So I am trying to get i2c over GPIO by GPIO bit-banging. How to use i2c-gpio driver? Where to set the gpio pin numbers for SCL and SDA?
View 1 Replies
View Related
May 25, 2010
How to create random numbers between -5.0 to +5.0
View 12 Replies
View Related
May 10, 2010
I'm working with a rather large file of data taking from a tracking program on my phone, and trying to pull only the longitude and latitude from it. Any given line in the data looks more or less like this:
{"lon":-122.3083848,"time":1.273515839496E9,"source":"skyhook","nap":28,"altitude":0,"name":"location","hpe" :29,"bearing":0,"ncell":0,"lat":47.6544453}
I've run it through this command:
grep skyhook log-2010-05-10_18-17-28.json | cut -d"," -f1,10
to get this:
{"lon":-122.30872015,"lat":47.65812201}
{"lon":-122.3076686,"lat":47.6569975}
{"lon":-122.3079161,"lat":47.656395}
{"lon":-122.3096168,"lat":47.656218}
{"lon":-122.3096285,"lat":47.656206}
Which is a lot nicer, but I would prefer not to have to hand remove the non-number characters by hand since there are thousands of data points. what I could do to get it to just be longitude and latitude in 'number number' format?
View 8 Replies
View Related
Aug 1, 2011
Does any one know the process or commands to get the serial no: of a h/w device from a host?
I am looking for serial No: of Hdd,Graphic card,processor,RAM
I can get the serials of HDD & RAM using hdparm & dmidecode,but don't know how to get it for processor & Graphics card.
View 6 Replies
View Related
Mar 17, 2011
I want to use the Alt + numbers function in Ubuntu but I don't know how> I researched it first and i read I had to do Shift + Ctrl + numbers but ti doesn't work,
View 4 Replies
View Related
May 13, 2010
I want wondering if I can ls files that start with numbers only in a folder.
Suppose:
001.txt
302.txt
[code]....
View 6 Replies
View Related
Apr 20, 2011
Firstly I would like to say that Linux is very cool, especially the CLI. I have been trying to learn how to do some things in Fedora after being told Fedora was a good distro to get my feet wet. I have run into some issues and cant seem to find any answers. What Linux utility can be configured to automatically save the current logs?
How does your Fedora get an IP number? What IP numbers has your Fedora been assigned since it was installed (based on the logs you have)? What command did you run to determine the IP numbers? What command would you run to determine the number of times a user successfully used "su"? What command would you run to determine the number of times a user unsuccessfully used "su"? Having some issues with the file system as your Fedora boots up.
View 5 Replies
View Related
Jun 3, 2010
Any way to show the permissions with numbers (777) instead of with letters (drwxrwxrwx) using "ls" command or any other command ?
View 2 Replies
View Related
Mar 1, 2011
I am trying find files in a directory that contain numbers. I have tried ls /etc *[0-9]* but that doesn't work. If I cd to /etc and run ls *[0-9]* it almost works but it also includes results from within files. My last thought was to try: find /etc [0-9] -type f but this does not work either. My second problem is that I am trying to get list of files in a directory that were changed less than 10 hours ago, using grep, while leaving out directories. I am completely stuck with the second problem.
View 8 Replies
View Related
Oct 6, 2009
In the file /var/log/kern.log, I see kernel logs in the following format,
Oct 6 11:18:30 machine kernel: [212.443755] Some logs...
What are the numbers in the bracket [212.443755] stands for?
View 2 Replies
View Related
Feb 27, 2010
I am a newbie in Linux. Here is my question....
Create the file ~/license_counts, which tables the number of occurrences of packages which are licensed under a given license, for the top 5 most commonly used licenses, sorted in numerically descending order. If performed correctly, your file should be formatted similarly to the following. (Do not be concerned if the actual counts or license names are different. Also, you might notice logically similar licenses, such as LGPL/GPL and GPL/LGPL. Do not make any attempt to combine them into a single entry.)
The resulted format:
I tried some method but cannot get it to work.
View 2 Replies
View Related
Jul 20, 2010
Is it possible for listing directory and files' permission into numbers?
Generally ls command shows directory and files' permission as follows;
[root:maestro:/home/ddisk_net]# ls -al
Total 44
drwx------ 4 ddisk_net users 4096 7월 20 10:40 .
drwxr-xr-x 21 root root 4096 7월 20 10:28 ..
-rw------- 1 ddisk_net webteam 5 7월 20 10:40 .bash_history
-rw-r--r-- 1 ddisk_net users 33 1월 22 2009 .bash_logout
[code].....
View 9 Replies
View Related
Apr 22, 2010
I am using RHEL 5. In my Linux Box I have two Lan cards (eth0 and eth1). "eth0" is connected with network 192.168.10.0 and "eth1" is connected with network 192.168.11.0. Both Network are inter connected via routing. Now I want a situation where, I want to dedicatedly assign some port numbers against a lan card. Like eth0 will be assigned for ssh (22) and eth1 is assigned for telnet (23). So that, when a user connect to 22 port then he/she is connected to the server through eth0 , and when a user connect 23 port then he/she is connected to the server through eth1. Is it possible to do using iptables or other?
View 2 Replies
View Related
Sep 6, 2010
Is there a command to return a recursive listing of sub-directories and the number of files in them? I have found plenty of ways to give me the total number of files in a directory structure, but none that gives a list of the sub-directories with the number of files in them. "du" gives me a listing of directories with their sizes, but I couldn't find an option (or any other way) to give me the number of files as well. Ideally, I'd like to get list with "Size" "Files" "Dir name" - And the order of the columns doesn't matter. Is there a "simple" command line solution or do I need a shell script for that?
View 5 Replies
View Related
May 19, 2010
To encrypt the text, we take the word "python" and make it at least the same size as "welcome home" by repeating it as follows:
w e l c o m e h o m e
p y t h o n p y t h o n
Then, we convert each letter into its numerical ASCII value as follows:
w e l c o m e h o m e = 119 101 108 099 111 109 101 032 104 111 109 101
[Code].....
And, finally, we convert the numbers back into their corresponding ASCII character:
View 11 Replies
View Related
Aug 21, 2010
I have huge files, wherein some lines begin with a number. I want to convert that number to a bookmark link
Sample file:
Code:
C.S. Lewis (I think) wrote:
1 If war is ever
2 legal, then peace
3 is sometimes
4 sinful.
Text without numbers toom I need the numbers to be <a name tags where the id is the letter x and the number that is at the beginning of the line:
Code:
C.S. Lewis (I think) wrote:
<a name="x1">1</a> If war is ever
<a name="x2">2</a> legal, then peace
<a name="x3">3</a> is sometimes
<a name="x4">4</a> sinful.
Text without numbers too I'm not sure why I can't get this, but after hours of 3 line long seds and endless while read lines, grepping ^[[:digits:]]s I can't figure it out.
View 3 Replies
View Related
Apr 11, 2010
I am trying to find a way to replace a set of sequential numbers in a file with a different sequence using sed. This might be done easier using awk or some sort of bash script, but it seems to me there must be a way to do this easily with sed. Basically, what I am editing is a Cisco switch config. I want to change the sequence of ports to a different numbered sequence. Here is an example of what I am trying to do.I want to change for example, the file:
Code:
cat testfile
interface FastEthernet0/1
[code]...
View 6 Replies
View Related
Jun 21, 2009
I have a text file with content that look like this..
Code:
1,3927,"AIS"
1,6928,"AIS"
[code]...
View 13 Replies
View Related
Dec 31, 2010
I am looking for a way to search for large numbers in text files and print the nearby lines.
For example if I had a text file like:
Event: 11
blah: 3
blah: 41 bleh: 19
Event: 2
blah: 31
[Code].....
View 1 Replies
View Related