I’m running an awk command in a shell script, and it’s breaking the datafile. All of the data doesn’t load, and there’s a newline character at the end of each line. If I run this as a command, it works perfectly. I’ve just found that i can use fflush() and it seems to have solved…
Tag: linux
Pop function for stack has unexpected behaviour [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 6 years ago. Improve this question I was just taking lecture on behalf of my Guide and one student given this…
Get information in the Log file
I have a log file and below is sample log in that file. I changed only here column 3rd and 4th as SourceNo,Destination for reference. my requirement – I need to get separately, Source wise total count that sent to Destination begin with 44 code. i tried with grep and awk but it didn’t work. apprec…
How to gather IP and User Agent info and uniq them base IP address from nginx access log with AWK?
i have a sample log file I want to collect all the ip and user agent info to a file, and uniq the same IP address, how can i do with awk ? output like: Answer With sed, sort and uniq :
How to code a shell script to run a program when the system login? [closed]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack …
Cronjob script isn’t working as expected
I have a script that work perfectly fine when I manually run it by myself, but does not seem to run properly from crontab. The main error is that the (external) environment variables are not being set. I added SHELL=/bin/bash above the cronjob definition but still got the same errors. The script I have copied…
Undefined references when linking with gcc -lnetsnmp
I’m trying to compile and run my code on a raspberry pi which needs the snmp libraries. However, I get linking errors such as “undefined reference to ‘EVP_DigestUpdate’”. I’ve been researching this issue for the past few days and found out that this usually happens when snmp can&…
Print text in between a string pattern and a new line in bash
I have a text file that looks like this: and I’m trying to print the part between 29.04.16_09.35 (included) and the first empty line. I thought sed would work and tried using this code: but it prints everything from 29.04.16_09.35 to the end of the file. I also tried by using a single n but it still pri…
bash date, create a new object on a specific timestamp that is n hours later from now
I am struggling to understand how to set a variable to be a particular timestamp. given dt which is the current date, say 2016-05-11 17:10:00, i want to create another date variable that is (roughly) 9 hours after dt, and on the exact hour, i.e., 2016-05-12 02:00:00. In other words, I would set the new date t…
Linux screen snapshot/redirect
Is it possible to take a “snapshot” of a running screen command, either stored as text or an image? Something akin to the following: Answer It’s possible to take so called “hard copy” of a screen session: Here we send hardcopy hc.n command to screen session 11534.test. The sessio…