"&>" and "<&" token questions

I'm a little confused about the <& and >& tokens and I've included an example with my question. On the bottom of my example, couldn't I just use <3 and >4 as arguments to cat? I know you can't because I've tried it but I just don't unde...
more »

2017-05-31 00:05 (1) Answers

C : Best way to go to a known line of a file

I have a file in which I'd like to iterate without processing in any sort the current line. What I am looking for is the best way to go to a determined line of a text file. For example, storing the current line into a variable seems useless until I g...
more »

2017-05-29 16:05 (4) Answers

Storing element in string

Question: In my code, what ever I enter for n, compiler allows me to input and output only half of it. Why? #include<stdio.h> #include<stdlib.h> int main() { int n; scanf("%d\n",&n); char *c= (char*)malloc((n+1)*...
more »

2017-05-20 11:05 (2) Answers

Intentionally cause a read/write timeout?

I'm trying to test some file io and I was wondering if there's a way to emulate the following situation: I have a block-storage device that is constantly being read/written from, but I want to notify the users of the proper error when they are tryin...
more »

2017-05-18 04:05 (1) Answers

Java searching file

I have 2 string variables: "givenAccnt" is the input string obtained from user "accntToken" is a substring (first string) of a line of text If givenAccnt equals accntToken, I want to return the line of text matched by accntToken. Furthermore, the...
more »

2017-04-25 05:04 (1) Answers

Java exec method, how to handle streams correctly

What is the proper way to produce and consume the streams (IO) of external process from Java? As far as I know, java end input streams (process output) should be consumed in threads parallel to producing the process input due the possibly limited buf...
more »

2017-03-13 09:03 (2) Answers

printf formatting equivalent in cpp's cout

I am currently a student of Computer Science, and today I received an extra-ordinary assignment, which should be written under C++. I was learning full C until today. This is more like a blind assignment. In C, I usually use this: printf("\n\n\t%-3...
more »

2017-03-08 14:03 (2) Answers

Ruby File.open not creating file

I'm trying to create and write to a new file using @logFile = File.open("C:\Users\---\Desktop\mylog.log", "w+") And nothing happens. My program uses @logFile.write ("Hello") @logFile.flush And this line seems to be running ok (no crashes ...
more »

2017-01-19 13:01 (2) Answers

Java - text to array to text

I'm looking for the best way to read integers+strings from a small text file, save them in an array, add a few new integers+strings, sort them by integers and then write highest few in the same file. (sth like highscores) Example: sth.txt: 5 aa 4 ...
more »

2017-01-17 20:01 (3) Answers

Measuring peak disk use of a process

I am trying to benchmark a tool I'm developing in terms of time, memory, and disk use. I know /usr/bin/time gives me basically what I want for the first two, but for disk use I came to the conclusion I would have to roll my own bash script that perio...
more »

2017-01-08 13:01 (2) Answers

Command output mangled on redirection

Given a directory with a few million files in it we want to extract some data from those files. find /dir/ -type f | awk -F"|" '$2 ~ /string/{ print $3"|"$7 }' > the_good_stuff.txt That will never scale so we introduce xargs. find /dir/ -type f...
more »

2016-12-28 23:12 (2) Answers

readChar from stdin

I would like to read in one character at a time and convert it to a string command to execute once a space is entered. I tried con <- file("stdin") open(con, blocking=TRUE) while(q!=" "){ #q=scan("",what="", nmax=1) q=readChar(con,1) cmd[...
more »

2016-12-18 08:12 (1) Answers

c stdout to stdin realtime

I have make two programs one of them named generator which print some text every second int main(int argc, char** argv) { for(int i = 0; i < 10 ; i++) { printf("something\n"); sleep(1); } return (EXIT_SUCCESS); } ...
more »

2016-11-04 19:11 (5) Answers

mysql i/o usage is very high

I have mysql running on RedHat EL 6.5 and mysql version - MySql Enterprise 5.6 Server configurations are as below - 1 processor / 4 cores Memory - 8GB Disc space - 256 GB Am experiencing very high Disk IO usage. Please share some advice/tuning...
more »

2016-10-17 14:10 (0) Answers

Close file after a kill command

I have an infinite loop in my program where it will write in a file defined as stdout until I kill it. Therefore, the file will never be closed and won't contain what was wrote. Is there a way to close the file after a kill command ? I could use s...
more »

2016-10-10 12:10 (2) Answers