Comments (3)
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.
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.
I disagree about it being "easy enough" to use pipes instead, especially because
- 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.
- 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)
- [Feature request] -p preview mode shows a diff of what would happen (with customizable differ) instead of just doing what sed does. HOT 2
- Release v1.0.0-beta.0
- Release v1.0.0
- Friendly ping to Arch packagers HOT 3
- v1.0.0 darwin x86 binary cannot be run right away as dev can't be verified HOT 8
- v1.0.0 changes package structure and breaks automated installs HOT 2
- v1.0.0 package structure doesn't work for `MANPATH`
- Is this possible? HOT 5
- Need to document that `sd` does _not_ stream, loads entire input into memory HOT 2
- Use something other than `$` for capture group prefix
- Feature Request: renaming files? HOT 3
- Update on maintenance status HOT 8
- `\s+$` matches newline at the end of the file and newlines on empty lines HOT 6
- sudo sd command not found HOT 2
- man page has blank description
- I translated a manual into Simplified Chinese HOT 3
- Are these features missing or not intended? Possibility in the future? HOT 2
- Maintainership, Archive, or Something Else? HOT 4
- README: advantages over `perl -pe`?
- Streaming mode without buffering multiple lines? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sd.