Many ways:
Using single quotes around name:
cat > 'Grocery list'
Using double quotes around name:
cat > "Grocery list"
Escape the whitespace with \
:
cat > Grocery\ list
When you do:
cat > Grocery list
Grocery
and list
are taken as two words.
The output direction > Grocery
is done by shell, and it happens first, so the file Grocery
is created, and then cat list
is run i.e. list
is taken as an argument to cat
, as presumably there is no file as list
present in the current directory, hence the error about missing list
file.
So, in this case, essentially you are doing:
cat list > Grocery
>
will overwrite the file; if you want to add more lines (append), use>>
instead. – derobert Sep 30 '16 at 18:00