I have a shell script which has to take arguments from the command line and pass it to a function in C. I tried to search but didn’t find understandable solutions. Kindly help me out. Should the arguments be passed via an option as a command in the shell script? I have a main function like this: How to …
Tag: linux
Set an external variable in awk
I have written a script in which I want to count the number of columns in data.txt . My problem is I am unable to set the x in awk script. Any help would be highly appreciated. data.txt file: Expected output: My output: Answer You just cannot import variable set in Awk to a shell context. In your example the
Linux loading i2c drivers
I have linux 4.4 on my board. I also have two i2c devices with their driver. When I connect first device to board – i see in dmesg that _probe function called. When I don’t connect any device to board – in dmesg i don’t see _probe function. When I connect second device – in dmesg…
Debugging segmentation fault with backtrace in cpp
In my code (written in cpp) I am getting a segmentation fault with following backtrace: So is there a way to debug this and get on which line segfault occurs? (I could not find any posts like this here, if it’s duplicate I will delete this). The code itself is pretty big so typing it here would not be c…
unlinking a file in linux
I am new to Linux and trying to understand some things. In my docker image I see that the error.log is linked to stdout. ln -sfT /dev/stderr “/var/log/apache2/error.log” What is the command to unlink this so the error.log is written again? Answer unlink and then touch the file. Then test the proce…
Hide information during bash debug run
We do debug run(bash -x ./my_script.sh) in a shell script to understand/show what it is doing. But in doing so it might show some sensitive information that I dont want to be visible, such as passwords. My script extracts the password from a secure vault and passes it as a variable within the script when requ…
How do I download a package from the command line with .NET Core from nuget?
Microsoft packages .NET Core on Linux for Ubuntu. I’m currently using that. I now want to install Json.NET which instructs me to use the Package Manager console and run, I’m wondering how I do that Linux. I see that there is a Nuget CLI, but it doesn’t seem like that’s available on .NE…
Part of the code in the child process spawned by fork() is skipped
I use fork() to spawn a child process to run some code, but I found that in the child process, some code like printf(“child is running”); below will not run, and when I remove the sentences in switch(), it will run rightly, I can’t understand why this will happen. Answer Like I said in the c…
What is the expected behaviour if file is written/altered while sendfile() is in progress
One thread writes to a file (or even delete it), another one calls sendfile() for that file simultaneously for overlapping positions. What is the expected behaviour here? Also, If my understanding is correct, sendfile call will just add a record to socket (file description, position, length) and return to cal…
grep lines that contain 1 character followed by another character
I’m working on my assignment and I’ve been stuck on this question, and I’ve tried looking for a solution online and my textbook. The question is: List all the lines in the f3.txt file that contain words with a character b not followed by a character e. I’m aware you can do grep -i R…