Skip to content

Unable to print usernames longer than 8 chars with “w” in linux

I am doing a linux script to extract which users are logged onto a machine, from where, and how long they have been idle. So far I have been using the “w” command in linux. However I now noticed that it truncates usernames and source I have three users logged on testuser testuser-new lala-testuser…

How to store value from grep output in variable

I am working on one bash script, in which I have to use the regular expression to match string and then store the output in a variable to reuse it. here is my script, I tried this many ways, but I am getting error : ./check.sh: MET-3-get-issue-id-from-branch-name: not found if I run individual grep command th…

Is it safe to assume memory page size is a power of two?

I am currently working on a portable C program which makes use of the memory page size (as returned by sysconf(_SC_PAGESIZE)). I know most often page size is a power of two to allow efficient management using bitwise operations; I found no guarantee of this anywhere, though. So how safe is it to assume page s…

How to kill a process in a system call?

I found out that sys_kill can be used to kill process from a system call, but when i compile the following code, i get the following error: Answer It is often not possible to call the entry point of a system call from the kernel, since the API is for use from user space. Sometimes the functionality is provide…

Calculating a sum of numbers in C shell

I’m trying to calculate a sum numbers positioned on separate lines using C shell. I must do it with specific commands using pipes. There is a number of commands: comand.. | comand.. | (comands…) printing lines in the following form: The result should be 22, since 1 + 2 + 8 + 4 + 7 = 22. I tried &#…