Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference between vi and touch

 
Joe Harry
Ranch Hand
Posts: 10124
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,

What is the fundamental difference between these two commands?
 
Joe Ess
Bartender
Posts: 9312
10
Linux Mac OS X Windows
 
Greg Charles
Sheriff
Posts: 2989
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10124
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34839
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic