Skip to content

Tag: unix

Replace line with double quotes

I want to replace a line with double quotes on OpenBox startup, like: with I use this command, but it does not work: It gives me this error: Answer The ampersand in the replacement string recalls the pattern in the search string. So you can just do this: Also, you can use single quotes on the outside, and dou…

Using the setuid bit in Linux

I have this C file: I compile it, set the UID and GID both to root and set the setuid bit, so that it looks like this: However when I call $ ./a.out I still get: What am I doing wrong? Answer The real user ID is still the user that called the program, but the effective user ID is

Print error for missing argument

I am trying to write a script which will check number of arguments for first and second number; if both variable entered, it will do the calculation; if one argument is missing, it will print error message. Here what I’ve done so far: I am always getting error message even though I enter both of the num…

Save all data into variable tcl

I have a code which i want to use to open a log file, extract the contents and save it into a variable so i can extract the data from the variable in the future. How do i do that? So far the code saves only the last data of the log file into the variable. I think the while

script for deleting queues using a certain prefix

i have a file named “Output_File.txt” containing a list of local queues and i want to write a script to delete those queues. what i wrote is: the problem is that the script does delete the queues but prints for every deleted queue the following output: how can i alter the code to delete the queues…

Recursively grep unique pattern in different files

Sorry title is not very clear. So let’s say I’m grepping recursively for urls like this: grep -ERo ‘(http|https)://[^/”]+’ /folder and in folder there are several files containing the same url. My goal is to output only once this url. I tried to pipe the grep to | uniq or sort -u…

How can I control the number of running processes?

I’m doing a shell script and the unknown situation occurred. I must execute a certain number of processes, lets suppose 12. But I want to limit the executions by ‘t’ each time. So if ‘t’ is 3 I would have to execute 3 processes then 3, 3 and finally 3. But I would like to do it a…