assume I wrote this script :#print_time..cat <file1.txt> | grep *.log | head -4 | tail -2 | helper | sort -r -n -k2#helper..while read line; do  linearr=($line)  (( time =${line[2]}  - ${line[1]} +0 ))  echo ${line[o]} $timedonetwo questions:1) why the first script works as expected only when I write it like this: cat `cat <file1.txt> | grep *.log | head -4 | tail -2`  helper | sort -r -n -k2 2) Should I use grep *.log or grep .log ?What the script does:given a file1, we want to read only 2 log files when the last one is the number 4 of all the .log files in the given file1:example :I want the first part of the script to read : tuesday.log and wednesday.logand after that to calculate the time of every log time of every person whose name is in the log's files: and this will be printed out : 
What's the difference between doing cat and between piping only
bash
To answer your question, the problem is with your usage of grep.Grep takes what you put as a literal, so if you grep with *.log, it will actively look for the character star * followed by .log, so it won't find anything. As a quick test, The command echo hello.log | grep *.log will return nothingThe command echo hello.log | grep .log will return the line