| Author |
Difference between vi and touch
|
Joe Harry
Ranch Hand
Joined: Sep 26, 2006
Posts: 8795
|
|
Guys,
What is the fundamental difference between these two commands?
|
SCJP 1.4, SCWCD 1.4 - Hints for you, SCBCD Hints - Demnachst, SCDJWS - Auch Demnachst
Did a rm -R / to find out that I lost my entire Linux installation!
|
 |
Joe Ess
Bartender
Joined: Oct 29, 2001
Posts: 8291
|
|
Manual page for touch
Manual page for vi
|
"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
|
 |
Greg Charles
Bartender
Joined: Oct 01, 2001
Posts: 2550
|
|
|
It's a strange question, since the two commands aren't even remotely similar. vi is a visual text editor (vi = visual. neat, huh?) It's visual compared to "ed" anyway, which just lets you see and change one line of text at a time. The touch command updates the timestamp on an existing file, or creates a new file if the file didn't already exist. It's good for testing things like Ant builds that are highly dependent on timestamps. Now if your file is a text file, or doesn't yet exist, opening it with vi, then issuing the command :wq to vi, would have the same result as touching that file. That's the only way the two commands are similar at all.
|
 |
Joe Harry
Ranch Hand
Joined: Sep 26, 2006
Posts: 8795
|
|
|
Ok from What I understood is that vi is a text editor but I can use it to create only new text files / edit existing text files and so on. But with the touch command as well I can create a new text file and in fact any type of files. So that was why I wanted to know the difference between these two commands. Please correct me if I'm wrong!
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26499
|
|
Jothi Shankar Kumar wrote: But with the touch command as well I can create a new text file and in fact any type of files.
Yes. So long as it is an empty file .
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
 |
|
|
subject: Difference between vi and touch
|
|
|