You are not logged in.
Pages: 1
Hello, when analyzing receipts, I often find commands that do not seem to belong to the coreutils sphere (nor to the emulated busybox).
E.g.: ! grep -qs
The similarity to “if” is obvious, but I do not understand how it works exactly.
Or again:
[ -s /etc/$i ]
Like the previous example, this should be a file check.
Are they perhaps part of the framework undergrowth with which Slitaz is managed?
If so, it would be useful to know where to find information about those commands and how they are managed.
Thank you!
------------------------------------------------------------------------
Salve, analizzando i receipt trovo spesso comandi che sembrano non appartenere alla sfera di coreutils (e nemmeno delle emulate busybox).
Es: ! grep -qs
si intuisce la similitudine con “if” ma non ne capisco l'esatto funzionamento
o ancora
[ -s /etc/$i ]
come l'esempio precedente dovrebbe essere un check file.
Fanno forse parte di quel sottobosco del framework con cui slitaz è gestito?
Se sì, sarebbe utile sapere dove si trovano le informazioni relative a quei comandi e come vengono gestite.
Grazie!
Offline
Hi gibor,
I doing test on debian, code below work on bash, dash shell.
Not specific to SliTaz
----
Ciao Gibor,
Sto eseguendo dei test su Debian, il codice qui sotto funziona su bash e dash shell.
Non è specifico di SliTaz
! grep -q debian /etc/debian_version && echo here
here
Offline
Hi Shann
I still don't understand how to use it.
https://www.pluralsight.com/resources/blog/cloud/conditions-in-bash-scripting-if-statements
If the condition “!” is equivalent to negation, the use requires the use of “if”.
E.g.:
if ! grep -qs ‘messagebus’ “$1/etc/passwd”
then
-
fi
In practice, if grep does not find the string in /etc/passwd, it executes the “then” command.
With the direct command, what happens instead?
[ -s “$1” ] &&
! grep -qs in “$1/etc/inetd.conf” &&
cat >> “$1/etc/inetd.conf” <<EOT
#rsync stream tcp nowait root rsync rsync -daemon
EOT
true
checks for the existence of /etc/inetd.conf
if grep does not find the string rsync /etc/inetd.conf then it executes the commands following &&
otherwise, does it skip “cat”?
Offline
Hi gibor,
For code you post, you are right and should read this.
[c][ -s "$1/etc/inetd.conf" ][/c] if /etc/inetd.conf file found return true
[c]! grep -qs rsync in $"1/etc/inetd.conf"[/c] if rsync string not found in /etc/inetd.conf return true
with [c]&&[/c] aka and logical, previous condition should be true to each part execute.
if file found => search rsync string executed
if file found and search rsync string not found => run cat command
if file found not true or search if rsync string not found not true => command cat not running
Hope i clear in explain.
Offline
Yes, thank you, that's better. However, the strange thing is that I can't find any literature on the subject.
Offline
Pages: 1
[ Generated in 0.043 seconds, 7 queries executed - Memory usage: 1.54 MiB (Peak: 1.77 MiB) ]