Skip to content

Tag: shell

Shell script: Run function from script over ssh

Is there any clever way to run a local Bash function on a remote host over ssh? For example: Yeah, I know it doesn’t work, but is there a way to achieve this? Answer You can use the typeset command to make your functions available on a remote machine via ssh. There are several options depending on how y…

Get lines that end with “$” in a text file

I have an output like this: What i want is just this line: To be more clear, I want those line ending with a specific string. I want to grep lines that have a / character at their last column. Answer You can use $ like this: As $ stands for end of line, /$ matches those lines whose last

Run processes with priority from shell (not “nice” )

I am looking for the equivalent command to nice, but for setting process priority and selecting the scheduler to use. I need to be able to type (or include in a script) something like run-with-scheduler batch a-big-long-command, or run-with-scheduler round-robin priority 10 to set the process priority and sch…

Find the sum of an infinite series

How can I find the sum of an infinite series? Series: My misbehaving example: Is it possible to carry out this method correct calculation or how to resolve this problem in other ways? Answer This series does not converge. It’s called the harmonic series and it’s known to do not converge. Moreover,…