This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Linux / UNIX and the fly likes Difference between vi and touch Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Difference between vi and touch" Watch "Difference between vi and touch" New topic
Author

Difference between vi and touch

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9353
    
    2

Guys,

What is the fundamental difference between these two commands?


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8877
    
    8

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
Sheriff

Joined: Oct 01, 2001
Posts: 2849
    
  11

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: 9353
    
    2

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: 30392
    
150

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Difference between vi and touch