Code Monkey home page Code Monkey logo

Comments (3)

crr0004 avatar crr0004 commented on May 23, 2024

I think it would be better to use sed to keep it more consistent with the previous paragraph

Know basic awk and sed for simple data munging. For example, summing all numbers in the third column of a text file: awk '{ x += $3 } END { print x }'. This is probably 3X faster and 3X shorter than equivalent Python.

from the-art-of-command-line.

hastinbe avatar hastinbe commented on May 23, 2024

I was going to make the same recommendation for sed -i 's/old-string/new-string/g' my-files-*.txt, and agree it's consistent with the awk/sed paragraph.

from the-art-of-command-line.

jlevy avatar jlevy commented on May 23, 2024

One reason to prefer perl is that sed doesn't by default support full regular expressions (not needed in this example, but inevitably required in some cases) unless you use the -r option. And this option also varies by platform, so doesn't exist on MacOS. Perl is similar across platforms. So even though I avoid perl in most situations, it arguably is preferable in this narrow use case.

Of course, in practice I tend now to use my own https://github.com/jlevy/repren as I'm tired of remembering these details. (It's the best I know of for flexibility but would be interested to hear of others.)

This reminds me we should include a good capturing groups example. I've added this as #115.

from the-art-of-command-line.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.