grep '.*[s]' file
grep .*[s] file
Why do you need quotation marks to let this work properly? In the second case, grep seems trying to inspect every file with a period.
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
echo '.*[s]' file
echo .*[s] file
This outputs the arguments as seen by the command.
In your first example you pass your
grep command exactly two arguments: the pattern and the file.
In your second example your shell will handle the first argument and replace it with all the files starting with a dot and ending in "s". Therefore your grep command will get multiple arguments and it will try to find the first (expanded) filename in all other expanded filenames and the explicitly specified file.