How can I email the output between file1 and file2 but only if there is a difference? Lets say I’m using a shell script. Answer Use the || concatenation. More info here
Tag: unix
Irregular result in zombie example
I have problems with understanding the behavior of this code: When running in a Unix shell I get this result: But sometimes its only giving me this result without any shell prompt: I know it can be solved with wait() function in parent process. But I like to know: Why is result irregular? Could someone please explain what happening? Child
a program to alert when /var files system usage reaches threshold
I am working on a program which will send an snmp alert when /var reaches maximum threshold. I am having trouble with calculating % of /var disk usage for this. I have this command “du -hs /var” which give me usage of /var in MB and /var is in the /root directory. So to calculate total disk on which /var
Check the parameter already in server
How to check the already set parameters in Linux/Oracle. For example, as soon as I login to Linux if I type cd $AU_TOP, it directly goes to the path set in AU_TOP. Now I want to see like AU_TOP what are the other parameters is there. Answer If typing cd $AU_TOP take you to some directory – Means you have
linux files and folders are not inheriting parent directory permissions
I created a directory /share and gave chmod 2770 permission and chown root:stock /share. 1) When I create touch a file inside /share, I see the file has rw-rw-r– and I don’t see rwxrws— 2) When I create a directory in /share/data I see the permission as drwxrwsr-x where are the parent directory is drwxrws— How can I get parent
Print grep Keyword if grep find a match
I have an input file Input.txt with the following sample keywords: I also have a file Text.txt to search such as: I want to print grep Keyword followed by a match if the grep finds a match. The desired output: Answer With awk you could do something like this: In a more readable format it would be:
Using sed piped with w command show user with the largest idle time
the w command produces something like this: I must get a sed script that prints the user with the longest idle time. But the problem is that w shows the idle time in 3 different formats: 1) in seconds: ending with an ‘s’, 2) mm:ss (not ending with ‘m’ or ‘s’), and 3) hh:mm (ending with ‘m’). So I need
Get last 30 minutes from log file
I have a log file that contain logs as follows 1486307866.155 is the time in unix format with corresponds to 2017-02-05 07:17:46 (Format : Y-m-d H:i:s) I need a unix command that give me the logs within last 30 minutes in the following format and discarding any details that i don’t need. 2017-02-05 07:17:46|68.146.231.80|clients1.google.com:443 Answer Using GNU date and GNU
Processing stdout and stderr separately adding a timestamp: Wrong order
These are my test files: std-test.sh: process.sh: std-test.sh creates twenty lines containing their line number, and process.sh is able to read another commands output when piped to it, while it saves to stderr when err is passed to it as argument, and to stdout when out is passed. The command I use to test the whole thing is: ./std-test.sh 2>
unexpected result(-wS-wx–T) on file permission with open() function in C
I wrote this program to open a file. Everything was OK until I saw this permission(-wS-wx–T) with ls -lh open.c I compiled the program featly, didn’t take any error or warning. I haven’t ever seen kind of permission. What are ‘S’ and ‘T’ meaning in the file permissions section? (NOTE: I took the answer to this question in the comments.)