Closed siarsky closed 3 years ago
Hi Siarsky,
Thanks for your question and your feedback.
Firstly, yes there will be some difference to unix commands as you know them. We tried to stick closely to a very minimal definition of the commands, but even there we have some deviation because unix4j uses some different concepts.
Firstly, we used the following command doc as a basis for our commands: https://pubs.opengroup.org/onlinepubs/009695399/utilities/sed.html
Note that some of the letters above are referred to as functions in the sed documentation, but implemented as options in unix4j.
In-place replacement is not currently directly supported by unix4j as this is a bit tricky to implement and typically requires random-access to files and/or in memory buffering of parts of the file, which unix4j does not implement (not sure how it is implemented internally in unix variants, they may also create a new temp file first and rename it at the end).
As a final note, please feel free to use unix4j as is if you like it (as many others do btw). If you do not like it then you have basically 3 options: (1) provide a pull request with fixes/enhancements/improvements (we are always happy to review and consider pull requests), (2) write your own tool (e.g. port a unix c source to java if you like), or (3) simply don't use it and look for another tool or implementation.
Thanks for your honest feedback. Regards, Marco
I believe Unix4j is promising too much for "sed" Implementation of Unix command line tools in Java. You can use the commands that you know from Unix in a Java program---you can pipe the results of one command to another as you know it from Unix.
The standard Unix "sed" options are listed in PS. Unix4j is implementing: -n
and other Unix4j sed options: -g -p -l (misleading, every sed use it as line-length parameter) -I -s -a -i (misleading, every sed use it as in-place replacement) -c -d -y
have nothing to do with an Unix sed. Or am I issing something? Could you please document, how to achieve a simple Unix sed search/in-place-replacement option "-i" in a file with Unix4j :
cat test.txt Unix4j is not such a great tool as I thought.
sed -i 's/is not/is/' test.txt
cat test.txt Unix4j is such a great tool as I thought.
or let me know if you have any plans to add an Unix "-i" sed option into unix4j package soon?
I you have no such plans, please list only those unix4j commands on your project page, which are implemented as a Unix command (like unix4j.grep).
Thanks siarsky
PS: