Skip to content

Tag: shell

Live Linux grep script – only print positive results

I try to code a bash 4 (or sh, if that’s possible) script that does the following: 1st parameter: the path to the compressed modules to search, could be “.” 2nd the search pattern to look for The script so far looks like this (be aware that it is not foolproof, it not checks if both paramete…

Extra percent sign appears in echo bash

I’ve got the following script below which is supposed to demo CPU utilization: For some reason, when the percentage is echoed out, two percent signs appear instead of the last digit of the number and a percent sign. For example, the output is sometimes 2.7%% instead of 2.72%. Everything works fine when …

Understand the basic concept of a Makefile

I have the following makefile which I am trying to upgrade, but there is a certain element which I am not able to understand what means: I understand that $(OBJDIR)/%.o: is obtained by executing the f90 compiler with flags etc. But why do I need the %.o rule, and what does @make mean. Am I missing a general u…

Why are some Bash commands both built-in and external?

Some commands are internal built-in Bash commands while others are external (other programs). I see why certain commands need to be built-in. Some of the reasons are: If a command needs to change the internal state of the shell process. If a command performs a very basic operation in the shell. If a command i…

Preventing expansion/evaluation of parameter in ssh command

I have a shell script that runs a docker container on a remote server. I’m trying to send the hostname of the remote server into the container but i just get the hostname of my local computer where i run the script. The command looks like this in the script: Both hostname and the environment variable ho…