Originally Posted by sunil80
In past days, sometimes by mistake i run the command,
"cat > /etc/passwd" and it get clear when i press CTRL+Z, CTRL+C or CTRL+D.
Can I exit this command without changing my file.
The problem is that bash opens the file /etc/passwd with the truncate as part of the "> /etc/passwd" handling before the command ("cat") is even executed. What happens after bash opens the file, is that it is passed to the "cat" utility as stdout.
Terminating the command by ctrl-c (interrupt) or ctrl-d (end of file), just closes the file - leaving it with nothing in it.