• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

simulate unix commands with java

 
Rajag raja
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,

Please help me in simulating Unix commands in JAVA

ls command of Unix with options like –l,-t,-P,-R

grep Command in Unix with options
a) to print lines matching patterns in file b) Line number in file matching the pattern
c)no. of times the pattern is present in file

to simulate menu driven program for commands
a) Head b) Tail c) diff d) comm.


simulate a Pass-1 of an Assembler for sample ALP code
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15219
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What exactly do you mean by "simulating" what those programs do with Java?

Do you mean write Java programs which do what ls, grep, etc. do? That would not be very easy. Implementing grep is not simple, and writing an assembler is also definitely something that will take a lot of time.
 
Henry Wong
author
Marshal
Pie
Posts: 21024
78
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rajag raja wrote:
ls command of Unix with options like –l,-t,-P,-R


The ls command just list files (and directories) in directories. I guess you should start with the java.io.File class. There are methods that list files.

Rajag raja wrote:
grep Command in Unix with options
a) to print lines matching patterns in file b) Line number in file matching the pattern
c)no. of times the pattern is present in file


This one is a little bit harder. The "re" in "grep" is short for regular expressions -- so you would likely need to learn regular expressions first. In Java, regular expressions are accomplished by the java.util.regex.Pattern and java.util.regex.Matcher class.

Henry
 
Rajag raja
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply.But these programs are given as simple programs as part of lab exercise for B.E course.Please help me with the code for which i will be thankful to you.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure. What do you have so far, and where are you stuck making progress? If you haven't started, what ideas have you had?

Note that people here will not write the code for you, though. That would unfairly rob you of the educational value of figuring it out yourself.
 
Rajag raja
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



O.K. what about System Programming in Java?
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What about it?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic