I need to use the following grep command in a shell script:
grep 'DUE TO TIME LIMIT' ./slurm-3364.out
Which outputs the lines in slurm-3364.out containing the pattern 'DUE TO TIME LIMIT'. I want to replace the file name with a variable and affect the output to a another variable. So far I can't get the same result, I tried:
jobOver="$(grep 'DUE TO TIME LIMIT' "$NEWEST")"
echo $jobOver
With $NEWEST containing the appropriate file name. This produces a very long text output that seems to list every file in the working directory...
Edit: As mentioned in the comments, doing echo "$jobOver" solved the problem.