I need some help because I don’t get something. From what I read from Internet, a subshell is created when we execute a shell script or if we run command in brackets: ( ) I tried to test this with a script which contains only the following command: When I run it I see the following result: Which is good…
Tag: linux
How to send signal to program run in a docker container?
I have a program run in a docker container with detached mode. So how to send a signal such as SIGINT to this program? Answer You can use nsenter to get into your container space and send your signal. More info : http://jpetazzo.github.io/2014/06/23/docker-ssh-considered-evil/
awk sum every 4th number – field
So my input file is: I want to sum the numbers then write it to a file (so i need every 4th field). I tried many sum examples on the net but i didnt found answer for my problem. My ouput file should looks: Thanks! Update: The problem is the same. I want to sum the 3th numbers (But in
Why does QCoreApplication call `setlocale(LC_ALL, “”)` by default on Unix/Linux?
I think that it’s safe to say that C locales are universally recognized as a bad idea. Writing an application that tries to parse or write text-based machine formats (which happens quite often) with C standard library functions gets near-impossible if you have to account for locale being set to anything…
How to select the nth char from a string for each line in a file?
Every line has a word and a number. I need somehow to select the nth letter which all together will make a new word. For example: it has to start like this and I’m only allowed to use sed (no awk, perl, …). I know how to select all the numbers or the text and I was thinking about but
popen (“tar xvf tarball.tar”) works in debug but not release builds
I’m working on a C++ program for Ubuntu that downloads a tar archive using curl_easy_perform, and after the archive is downloaded into /tmp I use popen to execute the appropriate tar command line. When I run my program’s debug build then popen(“tar xvf /tmp/example.tar -C /tmp/existingdir…
Use terminal to display image without losing focus
I have a bash-script in which I want to display an image to the user. This is possible using ImageMagick’s display. But now the focus of the terminal window is lost, and is placed to the image. To continue my bash-script I have to ask the user to click on the terminal before continuing. This is unwanted…
trouble with opening file for read with fopen
I am new to writing c under linux so this will be maybe silly question, but I have problem using fopen. When I encountered the problem I just tried it with this really simple code: test.txt is in same folder as this code and a.out. When I debug a.out I get: I tried changing the path: if( fopen(“/home/h1…
How to scp back to local when I’ve already sshed into remote machine?
Often I face this situation: I sshed into a remote server and ran some programs, and I want to copy their output files back to my local machine. What I do is remember the file path on remote machine, exit the connection, then scp user@remote:filepath . Obviously this is not optimal. What I’m looking for…
How to read a file line by line
I try to read a file line by line. File to read: Script: When I execute the script, this window will be opened: (Notice how some values are repeated, and the contents don’t correctly alternate between names and versions): I’d like to create an array with all package names and versions. Answer You …