I don't understand why this grep command display result this way. Why does it output the file name? And why is it separated by a double dot sign? Is it a regex?

[root@centos2 ~]# grep . /sys/block/sda/sda?/start

The ? in your command is a shell glob. The shell expands that glob to pass three parameters to the grep command, the names of each of the three files it's printing. The grep command senses that you're searching multiple files, so it prepends the filename that the expression you're searching for was found in to the actual printout of the expression. Since your pattern is a single dot (.), grep interprets this pattern as "any single character", which every line of all three files would satisfy. Each of those three files is only one line long, so it prints that one line for each file. Prepending the filename, you get the output you see above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.