How to avoid multiple OR statement bash
Generally, no, unless the effects of each flag are independent. You could try building up the arguments to grep
in an array. For example:
grep_options=()
if [ $w == TRUE ]; then
grep_options+=( -w )
fi
if [[ $s == TRUE ]]; then
grep_options+=(-s)
fi
# etc.
grep "${grep_options[@]}" search_pattern INFILE
using Grep or Sed to get a text beetween {}
Didn't realize that OP has {
and }
in two separate lines. sed
would be easier,
$ sed -n '/{/,/}/{//!p}' inputfile
For square brackets, you have to escape the characters:
$ sed -n '/\[/,/\]/{//!p}' inputfile
inputfile:
$ cat inputfile
Some text inside
{
between braces
}
some other text
[
between square bracket
]
some more text
output:
$ sed -n '/{/,/}/{//!p}' inputfile
between braces
$ sed -n '/\[/,/\]/{//!p}' inputfile
between square bracket
If they are on the same line, use perl-style-regex
in grep
and option -o
:
$ echo 'Some text {between}' | grep -o -P '(?<=\{).*(?=\})'
between
$ echo 'Some text [between]' | grep -o -P '(?<=\[).*(?=\])'
between
Is there elegant way to terminate running instance of spring boot stand alone application?
You can shutdown spring boot application by enabling actuator shutdown end point /actuator/shutdown
, first we need to enable it here
management.endpoint.shutdown.enabled=true
endpoints.shutdown.enabled=true
And then invoke it
localhost:port/actuator/shutdown
How to figure out what is running on my (NVIDIA) GPU?
See all processes being run by the user who used the GPU. Kill all processes that may have used the GPU.
ps -ef | grep <username>
You could also try
sudo nvidia-smi --gpu-reset
If nothing works then consider rebooting.
Regarding PID Shell Script
You may background testarg.sh
, which puts its pid into $!
, and then wait
for it:
#! /bin/bash
...
$CUSTBIN/testarg.sh &
LOGFILE=testarg.$(date +%d%b%y).$!.log # testarg.09Jun10.12345.log
wait $!
# ... $? is set as you expect ...
[ -f $LOGFILE ] && grep {pattern} $LOGFILE
...
Related Topics
How to Fix Java.Lang.Module.Findexception: Module Java.Se.Ee Not Found
How to Convert Hex to Ascii Characters in the Linux Shell
What's the Difference of Section and Segment in Elf File Format
Aborting a Shell Script If Any Command Returns a Non-Zero Value
How to Run Script as Another User Without Password
Sorting Multiple Keys With Unix Sort
How to Run a Perl Script as a System Daemon in Linux
How to Kill a Process by Name Instead of Pid, on Linux
What Killed My Process and Why
How to Extract Duration Time from Ffmpeg Output
How to Redirect Output to a File and Stdout
How to Remove the Lines Which Appear on File B from Another File A
What Is the Meaning of So_Reuseaddr (Setsockopt Option) - Linux
How to Get the Total Cpu Usage of an Application from /Proc/Pid/Stat
How to Get Docker Linux Container Information from Within the Container Itself