Each line represents a portion of a data matrix. I want to convert the numbers after the "=" to the range of that partition in the matrix such that the output file looks like this:
Basically, I am provided with a file "temp.dat" with 30 high temperatures (integers) in it. The program is supposed to read them in and compute/print the average. Then it is supposed to print the temperature of each day and, in addition, display a + by each day that is over the average, but only if it is above the average high for three or more consecutive days. This is the part I am stuck on. I'd appreciate any tips that would point me in the right directionFull disclosure: This is a school project. Code:
I have a file with three consecutive blank lines. I want to delete two and keep one.Also, if anyone could direct me towards a guide on regular expressions particularly as they apply to sed, I would be grateful. I am having a hell of a time figuring out the syntax.
As awk programmers may know, we can print range of lines with awk, from an initial pattern until a final pattern as follow:
Code:
awk '/Initial_String/,/Final_String/' inputfile
Well, I have this inputfile:
Code:
[code]...
Once having those elements in that way within an array(a[]), I want to be able to manipulate the array (a[]) and copy its elements to another array (b[]) in different order (all lines joined in a single line separated with commas), as follow:
I'm working on a script to table the outputs of various commands that depend on each other. The commands are these:
Code:
[root@kybsdc2 ~]# raw -q /dev/raw/raw1 [root@kybsdc2 ~]# sginfo -a /dev/dm-5 | grep Serial [root@kybsdc2 ~]# multipath -ll
which give these outputs:
Code:
#/dev/raw/raw1:bound to major 253, minor 5 #Serial Number 'P3e8hZWrsSeX' #netapp (360a9800050336538685a577273536558) dm-5 NETAPP,LUN [size=1.0G][features=1 queue_if_no_path][hwhandler=0][rw]
[code]....
Also the RAW13 device has completely wrong output due to 1 occurring more times throughout the sequence causing more information to be displayed then needed. The last point is if I could somehow remove the '' in the serial number outputs and the = sign from the device sizes. I guess I will have to either put a whole lot of logical IF or CASE statements in but somehow I need to streamline and make this code dynamic!
I just started learning shell programming and I'm trying to create a shell script that produce something like this: Input: 1 234 5 678 9 Output: < <<< 5 >>> > Input:abc d 1234 5 5 67890 e f ghij Output:abc d <<<< 5 5 >>>< e f ghij Characters with values less than 5 will display '<' digit values greater than 5 display '>'. The digit '5' will be left unchanged.
Below is my unfinished code: #!/bin/sh read userInput for f in "$userInput" do f1="$(echo ${f} | sed "s/[^0-9]//g")" if test $f1 -lt 4 then f3='<' elif test $f1 -gt 6 then f3='>' fi f2="$(echo ${f} | tr "$f1" "$f3")" echo $f2 done
I need to part a string into separate integers ....like "0x0-0xffffffff,0x20000" into 3 integers 0x0 and 0xfffffff and 0x20000.... i can't use any other high-level languages ..
I've googled til my brain went boom... So the short story goes; I have lots of ip address ranges in multiple files which need to go into an iptables firewall... Sounds simple right?
Example of files: 1.0.1.0-1.0.1.255 1.0.1.0-1.1.0.255
I have a python script that i want to convert to shell for a specific reason. The converted script should also be able to accept a command line arg such as hostname, which the current python script doesn't.
I want to write a bash script that will assign a successive number to a file if a file of the same name is moved into the same directory. So if there is a file called Notes in a directory and another file called Notes is moved into the directory, it will call it Notes.2.
i have a text file generated automatically from a script , but the result in the script is not ordered in a readable way, so i need your help to fix it using a shell command the text file contain data in this way :
i want to arrange the data in this text file in a way that each line will concatenate the 2 lines after it , so that will be 1 line , i want all the lines to be treated in this way ,
I am testing some bash script using -fx flags: #!/bin/bash -fx
Now when the program runs i get output in which i need to trace i my script the different lines. Is there some built-in flag for line numbers output on debugging?
i am having two small issues with a function i have made.sorry if it is a mess, i am still learning bash.the first is calling the nonpersistssh function (second line) and assigning the return value to nonpersistdiag.the function returns 1, but nonpersistdiag seems to only contain 0. i am unsure on how to proceed.the second problem is the nested else clause on line 10. it is a syntactical error. how would i declare it correctly?
Code: function endsession(){ nonpersistdiag=$[nonpersistssh]# a function that returns an exit code sudo /etc/init.d/ssh stop; sshdiag=$?
I need to frequently convert jpg/png to eps. Usually I use GIMP and it works fine. I would like to perform the conversion via shell (maybe with a script) without opening any graphical window. I used the command convert of ImageMagick but the quality is poor, I assume that it is because of some parameter to set I do not know. I know the question is trivial and full of posts around but I'm wasting time without finding what I'm really looking for.
I can use hexedit to manually edit one or two hex values in a binary file, but if I want to change many of the, this is impractical. Is there any tool that will take parameters like Code: someTool filename byteNumber replacementByte ?
The idea is to make a website to check the availability of domains and it works but its not pretty yet. Below is what i have till so far:
## this is the API from my domain registrar. <?php $client = new SoapClient('http://api.sync.com/?wsdl'); ## I have a search box that sends the request to this page $var = $_GET ["s"];
## remove the most common subdomains from the request. $var=eregi_replace("www.", "", $var); $var=eregi_replace("mail.", "", $var); $var=eregi_replace("ftp.", "", $var); $var=eregi_replace("pop.", "", $var); $var=eregi_replace("smtp.", "", $var);
## remove any TLD extension from the request. $split = explode(".", $var); $main = $split[0]; $arraysize = sizeof($split); for ($x=1; $x<$arraysize; $x++) { $tld .= "." . $split[$x]; } ## login to the API $paramLogin = array('handle' => 'randall', 'password' => 'password');
Result Login: Array ( [code] => 200 [message] => Login succesful ) array(3) { ["code"]=> string(3) "200" ["message"]=> string(20) "Domain not available" ["result"]=> object(stdClass)#236 (1) { ["status"]=> string(5) "TAKEN" } } bool(true) array(3) { ["code"]=> string(3) "200" ["message"]=> string(16) "Domain available" ["result"]=> object(stdClass)#232 (1) { ["status"]=> string(4) "FREE" } } bool(true) ?> ## till so far it works
What I need to do is to make this ugly looking reply in to something more readable, basically if TAKEN print occupied and if free print its yours to grab. I have been struggling with the in_array function but i'm not getting anywhere close in getting it to work.
I have been reading the Wikibook on C Programming for quite some time and am up to the variable part. I did learn several new things, like that too many variables hog memory.
What I want to know is how to assign a variable to the keyboard (in the C/C++ family) as such that the user has to type it in.
I have a application in C++, and now I have two class. MyDialog is the class that main function launch. In MyDialog class there are four elements and when I click over theese elements, there is a MousePressEvent that launch other class, Touchpad class. So, in some moments, I have loaded two class. My question is, how can pass a value from Touchpad class to MyDialog class, when I close (destroy) Touchpad class. In a few words, is it possible to communicate values between class?
Is it possible to use the keyboard in order to select some text in the terminal windows that is not in the currently edited line? (for example, in order to copy part of previous command output).
I am developing a script to automate some database setup, but I have an issue I cannot figure out. I prompt for some input with whiptail and select a default if nothing is entered. However, if you do not enter anything, it normally returns 0, but this time it is returning an empty value.