A data-oriented shell
File and Directory Management
Nushell can of course run standard file operations (copy, move, and remove files) just like Bash. It either uses built-in equivalents or calls out to external cp
, mv
, and rm
commands as needed. You can use mkdir
, rm -r
, and other commands in Nushell as you would normally. The advantage comes when combining these with structured queries. For example, to remove all files larger than 100MB in a directory (be careful with this!), use
ls | where size > 100mb | get name | each { |f| rm $f }
This lists files in the current directory, filters to those with a size greater than 100MB, and then extracts the name and runs the rm
command on each file. In a traditional shell, finding and deleting large files might involve parsing du
or find
output.
Logfile Analysis
System administrators often need to sift through logfiles. With Nushell, you can treat logs as data sources. While logs are plain text, you can use Nushell's parsing commands to structure them. For example, if you have an NGINX access log, you might use
open /var/log/nginx/access.log | lines | parse "{ip} - - [{date} {+*}] \"{method} {url} HTTP/{+*}\" {status} {bytes}" | where status == 500
Performance Optimization Tips
Despite all its features, Nushell is designed to be performant, leveraging Rust's speed and safety. However, working with structured data can introduce overhead compared to plain-text streams and certain usage patterns can be optimized.
Buy this article as PDF
(incl. VAT)