Skip to content
Advertisement

Tag: unix

How to make a strict match with awk

I am querying one file with the other file and have them as following: File1: File2: This command: returns lines that overlap, BUT doesn’t have a strict match. Having a strict match, only Helen Stanley should have been returned. How do you restrict awk on a strict overlap? Answer With your shown samples please try following. You were on right

Not able to start redhat httpd service

When I try to start the httpd service it is failing with the error : output of journalctl -xe . output of systemctl status httpd.service I tried to change the port number in httpd.conf file. But I got the same error. Can anyone please help? Answer try check your config, validate from command apachectl configtest

Recode value in the column in unix with awk or sed

In the following file, The values of 6th column for the rows who have values other than 1 or 2 in sixth column should be replaced with -9. How can I do it? old.fam new.fam should be Edit: I used cat old.fam | awk ‘{ if ($6==1 || $6==2) {print $1 ” ” $2 ” ” $3 ” ” $4

Simple sorting in linux

I’m quite new to linux, and I can’t quite get to understand sorting. I need to sort a long file by column 4 and then column 5, ignoring the first line. The catch is, there are two separators – ‘.’ and ‘,’ – I don’t know how to make sort command to include both of them. I guess it has

‘DT_REG Undeclared’ even when using header file in function

I’m using the <dirent.h> header file in the function I’m referencing DT_REG, however, I’m getting error an saying ” ‘DT_REG’ undeclared (first use in this function) ” The snippet of the code is: In my makefile I’m using “cc -std=c11 -Wall -Werror -pedantic”. Any ideas for the reason? Answer DT_REG is not part of ISO C11 extensions. Setting -std=c11 strictly

Protecting against Time-of-check to time-of-use?

I was reading: https://en.wikipedia.org/wiki/Time-of-check_to_time-of-use They showed this code to be buggy and I totally understand why it’s so: But the real question is how to protect against this type of exploits? Answer You can use the O_NOFOLLOW flag. It will cause the open to fail if basename of the path is a symbolic link. That would solve the described attack.

Python: Run command for another software in terminal

I am using a software that my lab has developed, lets call it cool_software. When I type cool_software on terminal, basically I get a new prompt cool_software > and I can imput commands to this software from the terminal. Now I would like to automate this in Python, however I am not sure how to pass the cool_software commands onto

Advertisement