[Solved] Error in shell script and how to write to a file [closed]

I think this question is fine now, the input file is good enough after edit, I can fully understand what you ask for now. With awk, you need learn to use 2-d array, it will simplify the code. awk ‘BEGIN{print “Instance id Name Owner Cost.centre”} /TAG/{split($0,a,FS);a[4]=tolower(a[4]);$1=$2=$3=$4=””;b[a[3],a[4]]=$0;c[a[3]]} END{for (i in c) printf “%-18s%-26s%-14s%-20s\n”,i,b[i,”name”],b[i,”owner”],b[i,”cost.center”]}’ file Instance id … Read more

[Solved] how to calculate area of polygon on a map? [closed]

From the formula of polygon, Area of ploygon = [(x1y2-x2y1) + (x2y3-x3y2) + …. + (x(n-1)yn – y(n-1)xn)]/2 Try, var arr=[ [10.075854059674523, 76.32832467556], [10.079825860518895, 76.33338868618011], [10.076234340596953, 76.33806645870209], [10.07065684212598, 76.33806645870209], [10.068924417668397, 76.33175790309906] ]; var sum=0; for(var i=0,l=arr.length-1;i<l;i++){ sum+=(arr[i][0]*arr[i+1][1]-arr[i+1][0]*arr[i][1]); } alert(‘The Area of Ploygon is:’+(sum/2)); Demo 6 solved how to calculate area of polygon on a map? … Read more

[Solved] SQL Join query to return matching and non-matching record

Your problem is coming from including columns in SELECT statement from table_2 that do not have values for rows that exists in table_1. You need to change SELECT Table_2.ScriptNumber to SELECT Table_1.ScriptNumber As future reference make sure you always select all relevant columns from LEFT tables and only columns you need from RIGHT table. Otherwise … Read more

[Solved] Get data type from String when the String have symbol [closed]

In this case (when the token defining it as a number is at the beginning): final String input = “Rp.1.000.000.000”; int value = 0; String token = “Rp”; if (input.contains(token)) value = Integer.parseInt(input.replaceAll(“[^012456789]”, “”)); Explanation .replaceAll(“[^012456789]”, “”) removes all non-numeric chars (R, P and . in this case). So the leftover is a String only … Read more

[Solved] Cout the last result only?

Just put the cout outside the for loop, like this: for (size_t i = 0; i < boo.size(); i++) { while (boo[i] == ‘a’) { count+=i+1; if(count>b) b=count; // cout<<<<“a=”<<b<<“\n”;; //remove from here break; }} //add here cout<<<<“a=”<<b<<“\n”;; 1 solved Cout the last result only?

[Solved] This confuses in javascript [duplicate]

The value of this changes depending upon how the function was invoked; Collection.prototype.onOpen(); // `this` refers to `Collection.prototype` // vs var c = new Collection(); c.onOpen(); // `this` refers to `c` // vs var o = {}; Collection.prototype.onOpen.call(o); // `this` refers to `o` // vs var foo = Collection.prototype.onOpen; foo(); // `this` could be `window` … Read more

[Solved] Name of current file PHP

basename(__FILE__, ‘.php’); See also here: http://php.net/basename, or, if you like pathinfo(__FILE__, PATHINFO_FILENAME); This last one works also if the extension is different from .php without the need to specify it, see http://php.net/manual/en/function.pathinfo.php 5 solved Name of current file PHP

[Solved] Customize html tag u, set it wider than text

Use a <span> instead of <u>. Add a border-bottom and some padding right and that’ll be that. HTML <span>Some text</span> CSS span { border-bottom: 1px solid black; padding-right: 40px; } Demo 2 solved Customize html tag u, set it wider than text

[Solved] Searching and Counting Greatest Values [closed]

First error: System.out.println(“the biggest value is: “+n+” and it is occurs “+H+” times”);}} The n is your TryCount. Should be: System.out.println(“the biggest value is: “+y+” and it is occurs “+H+” times”);}} Second error: You are increasing the count of the “highest” number: else if(y==f) H++; – but you are NOT taking into account, what should … Read more

[Solved] Read and print a user selected file’s contents [closed]

For what you are trying to do, a better method would be: import os def print_file_contents(file_path): assert os.path.exists(file_path), “File does not exist: {}”.format(file_path) with open(file_path) as f: print (f.read()) user_input = raw_input(“Enter a file path: “) # just input(…) in Python 3+ print_file_contents(user_input) solved Read and print a user selected file’s contents [closed]

[Solved] Java convert string to int

Assuming you have a string of digits (e.g. “123”), you can use toCharArray() instead: for (char c : pesel.toCharArray()) { temp += 3 * (c – ‘0’); } This avoids Integer.parseInt() altogether. If you want to ensure that each character is a digit, you can use Character.isDigit(). Your error is because str.split(“”) contains a leading … Read more