Bash: How do I stop bash from mindlessly writing millions of lines to console once it has begun?
Date : March 29 2020, 07:55 AM
To fix the issue you can do As others have said, use CTRL+C to interrupt. If for some reason this isn't working for you, open another terminal or console session on the same box and issue this command: ps -o pid=,args= -C grep
kill -INT $PID
kill -TERM $PID
kill -QUIT $PID
kill -SEGV $PID
kill -KILL $PID
ps -o pid= -o comm= -o args= | awk '$2~/grep/{print $1, $3}'
|
Need some help writing an if statement in UNIX bash scripting
Tag : bash , By : user171752
Date : March 29 2020, 07:55 AM
To fix the issue you can do I'm writing a reasonably lengthy script (or what I would consider lengthy - you could probably do it in a few hours). I basically have a file (named .restore.info) which contains files of names. In part of the script, I want to test "If cannot find filename in .restore.info, then says “Error: restored file does not exist”. Apologies if this doesn't make sense for you guys (for me, it does in the grand scheme of things). So if type this in the command line: , You probably only care if grep exits with a non-zero exit status: if ! grep -q "$1" .restore.info; then
echo "Filename does not exist!"
fi
if ! grep -q "$1" .restore.info && [[ $? -eq 1 ]]; then
echo "Filename does not exist!"
fi
|
Bash run docker command only if user has privileges (Bash if or statement)
Tag : bash , By : Nathan Good
Date : March 29 2020, 07:55 AM
this will help You should be combining them with &&, not ||. Suppose the user is in the docker group, but not root. [ $EUID -ne 0 ] will be true, while [ $(groups | grep -c docker) -ne 1 ] will be false. || is true if either of its operands is true, so this will make the whole condition true, and the error message will be printed.
|
Writing function with an if statement which executes when the statement is NULL or a string equivalent
Date : March 29 2020, 07:55 AM
will help you I would like to have an if statement which executes when the statement is NULL or a string equivalent: , This is one of those instances where you need to use || over | somefun <- function (number1, number2, type=NULL) {
if (is.null(type) || type == "sum") {
print(number1+number2)
} else if (type == "product") {
print(number1*number2)
}
}
> somefun(1,4,type="sum")
[1] 5
> somefun(1,4,type=NULL)
[1] 5
> somefun(1,4)
[1] 5
somefun2 <- function (number1, number2, type=NULL){
if(is.null(type)){
type <- "sum"
}
switch(type,
"sum" = number1 + number2,
"product" = number1 * number2
)
}
|
Writing shortened awk statement in bash profile?
Tag : bash , By : Lauren Kirschner
Date : March 29 2020, 07:55 AM
|