Skip to content

C fork and pipe multiple process

I’m trying to implement this command cat /etc/passwd | grep 1000 | cut -d: -f1 in C using system calls fork and pipe. When I use only two commands cmd1 | cmd2 so 1 fork it works fine but when I’m using more than 2 process the problem occurs Here is my code, I think the problem is in the

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…

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…