简体   繁体   中英

How to create grep command in java as linux grep command

I want a simple Java application which will work like linux grep command, also take input from pipeline.

Thanks

1st U have to check for command line args

if avail more than 2 arguments then, 1st one is radix and 2nd one is file name read file line by line, match the radix string, and print it

if command line is only 1 argument then you should check for System.in which comes from pipeline read line by line and check that single arg String as radix and print it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM