O
O
Oleg Ponomarev2021-08-22 10:41:37
linux
Oleg Ponomarev, 2021-08-22 10:41:37

How to understand the meaning of this line?

Can someone help me parse the meaning of this string

if /bin/ping -c 2 8.8.8.8 > /dev/null 2> /dev/null


Do I understand correctly that the ping command sends two packets and compares the receipt with nothing roughly speaking, but I don’t quite understand the last part of the line, namely
/dev/null 2> /dev/null

Answer the question

In order to leave comments, you need to log in

7 answer(s)
S
Saboteur, 2021-08-22
@zamsisadmin

each command returns a return code upon completion.
for if it is important not to compare something with something, but the return code of the command, which is 0 - success, not zero - error.
therefore if [ A == B ]- this is not a comparison, but the execution of a command [ ]
, so here if pingit is not a comparison, but the execution of a command pingand getting its return code
> /dev/null 2> /dev/null
>- redirecting stdout output to zero
2>redirecting stderr output to zero
This is to display the command did not output anything - neither the main output nor the
ps error, you can see the return code through the $ variable?

ping -c 1 google.com
echo $?

ping -c 1 google.com1
echo $?

K
ky0, 2021-08-22
@ky0

These are not mathematical operations. Read about streams and their operators in the bash. |, >, >>, ;etc.

R
Roman Sokharev, 2014-06-16
@greabock

Proper organization:
ID, SKU, ... , and other data common to all products with this SKU (for example, brand or brand ID (if brands are stored in a separate table); perhaps a link to the main image).
In general, the product itself is described here, as such.
variant_id, product_id, product options, balance.
Here are all combinations of possible options for a product, with a specific ID. As well as possible unique information for specific parameters (perhaps information that the product is promotional - let's say a 50% discount on super large sizes - here is a stock ID or something like that).
For example, if the options are size and color, then the table in this case is:
id, size, color, balance, and something else unique for this product variant (link to the image if the color is different, for example).
Of course, the combination of id + size + color fields must be unique in order to avoid duplicates.
If there are too many possible options for a product (and perhaps even the absence of some options and the presence of others), then you need to think about organizing a separate table of product options, but this is a topic for a separate discussion.

R
Rsa97, 2014-06-16
@Rsa97

Separate table (article, size, balance).

V
Vladlen Grachev, 2014-06-16
@gwer

You have a table with a list of products. Let's say products. It contains columns with the article (id), name, brand, etc.
Add another table like sizes. It contains the name of the size (L, XL, etc.), the remainder, the product_id foreign key, which refers to the id in the products table.
And on the product page, you get from the database not only data from the products table by id, but also from the sizes table by the same products_id.

Q
Quber, 2014-06-16
@Quber

You need to create a second table and name it size. It has four columns:
id
Poduct_id
Size
Count
When entering data into the table, the size, product ID and quantity in stock are indicated.

R
Reshad, 2014-06-19
@AIZER

1. It is possible to store in the database as an array, shared during the output, though then the 2nd point will not work.
2. You can make your own table with id + count for each property.
3. You can see how such things are implemented on large CMS IMs
4. You can generally apply a scientific approach and try to abstract from the semantic load by making functional dependencies and find the minimum coverage, although it may happen that at the stage of creating functional dependencies questions 1 and 2 are already resolved

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question