Coder Social home page Coder Social logo

Allow backup of input file about sd HOT 3 OPEN

chmln avatar chmln commented on August 26, 2024 5
Allow backup of input file

from sd.

Comments (3)

rahilwazir avatar rahilwazir commented on August 26, 2024 1

It will be great. But I think -o output flag will be more beneficial to create new file along with a choice to rename it as well. i.e.

❯ cat url.txt | sd -s 'google.com' 'google.test' -o url2.txt

Should output url2.txt with replaced string. But at the same time, it will easily be achieved via stdout

❯ cat url.txt | sd -s 'google.com' 'google.test' > url2.txt

But I agree what @whitfin has said #1 (comment)

from sd.

chmln avatar chmln commented on August 26, 2024 1

I believe backing up files before replacing them is an edge case for the majority of people. If someone is worried about making the wrong replacements, is easy enough to just use pipes and create a new file instead. e.g. sd abc def < important_file.txt > important_file.new.txt

from sd.

AndydeCleyre avatar AndydeCleyre commented on August 26, 2024 1

I disagree about it being "easy enough" to use pipes instead, especially because

  1. your example doesn't even accomplish the desired behavior here; the new content should be in the old filename, and the original content should be in the new filename. The way you have it requires extra work afterward to get to the final state, whereas the desired behavior only requires paying any attention to the backup file if something goes wrong/surprising.
  2. if you want to do this on a huge tree of globbed files, you'll have to make a loop that carefully manages each placement, and this increases the probability of user error by a lot

Thanks for the great project, btw!

from sd.

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.