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

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • FOSSPicks

    After building a 3D printer last month, Graham's home is now filled with cup holders, phone holders, cable holders, and tiny PLA boats. This month, Graham explores Zrythm, Mumble 1.3, NoteKit, Kirogi, monolith, pastel, Nu Shell, PacVim, Stunt Car Racer Remake, and more!

  • Spider, Spider

    Scrapy is an open source framework written in Python that lets you build your own crawlers with minimal effort for professional results.

  • Advanced Shell Scripting

    Shell scripting is a versatile tool for managing and automating the modern IT infrastructure. This article reaches beyond the basics with some advanced techniques for tackling real-world challenges.

  • Bash vs. Vista PowerShell

    Microsoft’s new PowerShell relies on .NET framework libraries and thus has access to a treasure trove of functions and objects. How does PowerShell measure up to traditional shells like Bash?

  • Tutorial – Shell Scripting

    You do not need to learn low-level programming languages to become a real Linux power user. Shell scripting is all you need.

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More

News