5 ms·
This looks interesting, but the examples don't really show off Marcel's power. The example you just gave without Marcel is: find . -type f -mtime -3 The exa
by js2 3y ago
This looks interesting, but the examples don't really show off Marcel's power. The example you just gave without Marcel is:
find . -type f -mtime -3
The example on this page: https://www.marceltheshell.org/list-processes https://www.marceltheshell.org/list-processes
ps -u djt | map (p: p.signal(9))
That's:
pkill -9 -u djt
The example for summing files by extension is a bit more interesting:
ls -fr | map (f: (f.suffix, 1)) | red. + | sort
Vs something like:
find . -type f | awk -F. '(NF>1){print "."$NF}; (NF==1){print ""}' | sort | uniq -c
That said, every time I look into one of these shells, I end up sticking with bash. When it gets to the point that I need something more powerful than bash and the Unix command line environment, I'd just as soon write a stand-alone program which I can check into version control, use on remote systems that don't have one of these fancy shells installed, add proper tests, etc.
This is a neat project though. I'll keep an eye on it.
- geophile 3y agoI actually agree with most of this. I tend to use Marcel for ETL sorts of processing, quick database access with data munging on either side, cluster access, etc. it works fine for basic shell usage though. As for a more complex example: yes, the website has better examples, but they are also more involved to explain.
- geophile 3y agoAlmost forgot: I also switch from bash to Python at a low threshold. In that case, I find Marcel’s API useful. I can then do shell-like piping inside of Python.
- Too 3y agoUsing the output of find into another program is not safe due to risk of file names containing delimiters. You need to use find -exec. Good example of why machine readable output is important. Agree that the tutorial should showcase more and larger such examples.
- rmwaite 3y agoYou can always use -print0. I suppose there is some risk of a null slipping into a filename but I’ve never come across it myself.
- gnosek 3y ago> some risk of a null slipping into a filename Only in some fairly esoteric environments: https://en.wikipedia.org/wiki/Filename#Comparison_of_filename_limitations https://en.wikipedia.org/wiki/Filename#Comparison_of_filenam...
- js2 3y agoYes, I know that, but it's also exceedingly rare for a filename to contain a newline and using -exec is extremely inefficient. I also wrote that on my iPad. Typically I'd use a combination of -print0 and xargs -0 for anything more formal than a one-liner on the command line. The larger bug in my example is that it fails if any of the directories in the path contain a "." in their name!
- eviks 3y ago[flagged]
- js2 3y agoIt's one example. I didn't realize the mistake when I wrote it. I wrote my comment in good faith. What's with the interrogation?
- queuebert 3y agoxargs also is good to use on big argument lists because it can parallelize the processing of arguments with the '-n' and '-P' flags.