29 Haziran 2021 Salı

bash kodlama - exec built-in komutu

Örnek
Elimizde şöyle bir kod olsun
#!/bin/bash

# Prepare the JVM command line
...

$JAVA_EXECUTABLE $JAVA_ARGS

# Clean up
...
Açıklaması şöyle
In this case the TERM signal is received by the shell process, but Bash will not forward that signal to the child process. This means that the shell process will stop, but the JVM will continue to run.
Şöyle yaparız
#!/bin/bash
... exec $JAVA_EXECUTABLE $JAVA_ARGS
Örnek
Sadece bazı komutların çıktısını stdout'a diğerlerini /dev/null'a yönlendirmek için şöyle yaparız
exec 3>&1 &>/dev/null
some_command
another_command
command_you_want_to_see >&3
command3
Açıklaması şöyle
You can use the exec command to redirect everything for the rest of the script.

You can use 3>&1 to save the old stdout stream on FD 3, so you can redirect output to that if you want to see the output.

Hiç yorum yok:

Yorum Gönder