How to print 5 consecutive lines after a pattern in file using awk [duplicate]

Another way to do it in AWK: awk ‘/PATTERN/ {for(i=1; i<=5; i++) {getline; print}}’ inputfile in sed: sed -n ‘/PATTERN/{n;p;n;p;n;p;n;p;n;p}’ inputfile in GNU sed: sed -n ‘/PATTERN/,+7p’ inputfile or sed -n ‘1{x;s/.*/####/;x};/PATTERN/{:a;n;p;x;s/.//;ta;q}’ inputfile The # characters represent a counter. Use one fewer than the number of lines you want to output.

ungetc: number of bytes of pushback

The C99 standard (and the C89 standard before that) said unequivocally: One character of pushback is guaranteed. If the ungetc function is called too many times on the same stream without an intervening read or file positioning operation on that stream, the operation may fail. So, to be portable, you do not assume more than … Read more

Call a Unix Script from Excel Vba

One option would be to open the plink session in a WScript.Shell instead of executing it with a script file using VBA’s Shell. The plink program will run in interactive mode from the command line, and the WshExec object gives you direct access to the standard input and standard output streams of the process that … Read more

longjmp() from signal handler

From the man page for longjmp: POSIX does not specify whether longjmp() will restore the signal context. If you want to save and restore signal masks, use siglongjmp() Your second question: Yes, the function will return -2 because longjmp() will cause it to go to the setjmp(buffer) part, but the timing will have to be … Read more

Unix O_CREAT flag without mode specified

The POSIX standard (IEEE 1003.1:2008) prototypes open() as: int open(const char *path, int oflag, …); The section describing the behaviour of O_CREAT doesn’t say what will happen if you omit the necessary third argument, which means the behaviour is undefined – anything is possible. In practice, the use of part of the stack that was … Read more