bash background process modify global variable

Upgrade 2019 Playing with bash_ipc_demo adding completion and a graph generator. Rendez-vous If you wanna have two independant process which could communicate, you have to place a rendez-vous somewhere both process can reach. This could be a simple file, a fifo pipe, a unix socket, a TCP socket or maybe else (Rexx port). bash and … Read more

Awk print string with variables

printf allows interpolation of variables. With this as the test file: $ cat file a,b,APPLE,d,MANGO,f We can use printf to achieve the output you want as follows: $ awk -F, ‘{printf “/p/%s_abc/xyz/%s_abc_def/\n”,$3,$5;}’ file /p/APPLE_abc/xyz/MANGO_abc_def/ In printf, the string %s means insert-a-variable-here-as-a-string. We have two occurrences of %s, one for $3 and one for $5.

BigInteger in C?

Use libgmp: GMP is a free library for arbitrary precision arithmetic, operating on signed integers, rational numbers, and floating-point numbers. There is no practical limit to the precision except the ones implied by the available memory in the machine GMP runs on… Since version 6, GMP is distributed under the dual licenses, GNU LGPL v3 … Read more

accessing a variable from another class

You could make the variables public fields: public int width; public int height; DrawFrame() { this.width = 400; this.height = 400; } You could then access the variables like so: DrawFrame frame = new DrawFrame(); int theWidth = frame.width; int theHeight = frame.height; A better solution, however, would be to make the variables private fields … Read more

Remove substring matching pattern both in the beginning and the end of the variable

Well, you can’t nest ${var%}/${var#} operations, so you’ll have to use temporary variable. Like here: var=”http://whatever/score/” temp_var=”${var#http://}” echo “${temp_var%/score/}” Alternatively, you can use regular expressions with (for example) sed: some_variable=”$( echo “$var” | sed -e ‘s#^http://##; s#/score/$##’ )”

Auto release of stack variables in C

You could use the cleanup variable attribute in GCC. Please take a look at this: http://echorand.me/site/notes/articles/c_cleanup/cleanup_attribute_c.html Sample code: #include <stdio.h> #include <stdlib.h> void free_memory(void **ptr) { printf(“Free memory: %p\n”, *ptr); free(*ptr); } int main(void) { // Define variable and allocate 1 byte, the memory will be free at // the end of the scope by … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)