Hi,
what is the meaning of -n option before the grep command ?
grep command searches for the specified string in the file tmp_crontab.txt
but what does -n mean ?
[ -n "`grep $some_string /tmp/tmp_crontab.txt`" ]
With Regards
Hi,
what is the meaning of -n option before the grep command ?
grep command searches for the specified string in the file tmp_crontab.txt
but what does -n mean ?
[ -n "`grep $some_string /tmp/tmp_crontab.txt`" ]
With Regards
Nothing with grep but with string :
[ -n "String" ]
returns TRUE if string is not empty.
likely [ -z "String" ]
returns TRUE if string is empty.
"`grep $some_string /tmp/tmp_crontab.txt`"
is a command substitution returning a string value. It can be better written "$(grep $some_string /tmp/tmp_crontab.txt)"
Example ($> stands for the prompt):
$> grep root /etc/passwd
root:x:0:0:root:/root:/bin/bash
$> STRING="$(grep root /etc/passwd)"
$> echo $STRING
root:x:0:0:root:/root:/bin/bash