grep -v *[^:] Why did this repeat a command i ran earlier today?

I ran grep -v *[^:] trying to reverse grep a word before a colon, and discovered it runs a command I had run earlier today.

Why?

It will never run a command.

But there are chances that after -v option, the pattern is not quoted. So that is taking all file as input & printing everything ....

Can you please explain the question better if you want us to answer exactly.

The geek is spot on of course. See this example

jonas merzky /tmp : l
-rw-------  1 user   group  10 Feb  3 02:10 file_1
-rw-------  1 user   group  10 Feb  3 02:10 file_2:
-rw-------  1 user   group  10 Feb  3 02:10 file_3:=

with quoting, the grep does what it is expected

jonas merzky /tmp : grep -v '*[^:]'
^C

w/o quoting, your shell will expand the command, and in particular the * will expand to all file names in the directory:

jonas merzky /tmp : echo grep -v *[^:]
grep -v file_1  file_3:=

*[^:] more specifically expands to 'all files which do not end in a colon'. The expanded command is what is being run, with different results than you intented I guess...

I think I know what happened, I copied the output of that command to a file and this grep read the whole file which made it look like it was running the command again.. the command was dtrace, and I had output the stdout to a text file.