Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 787245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:10:17+00:00 2026-05-14T21:10:17+00:00

Following the bash-hackers wiki’s recommendation , I want to edit files using ed. In

  • 0

Following the bash-hackers wiki’s recommendation, I want to edit files using ed.

In particular I want to do the following with ed instead of sed:

find . -type f -exec sed -i -e 's/a/b/g' {} \;

I see that ed doesn’t have opt like sed’s -e, so as far as I know, pipes and io redirections are the only way to work with it non-interactively.

So, using ed from a bash script to do the same as the above sed command would look like:

ed file_name <<<$'g/a/s//b/g\nw'

Or

echo $'g/a/s//b/g\nw' | ed file_name

But as far as I know it is impossible to involve pipes or io redirections within find’s -exec.

Do I miss something? or is the only way to overcome this is to use loops?

for file in $(find . -type f -print); do ed $file <<<$'g/a/s//b/g\nw'; done;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T21:10:18+00:00Added an answer on May 14, 2026 at 9:10 pm
    find . -type f -exec bash -c 'ed -s "$2" <<< "$1"' _ $'g/a/s//b/g\nw' {} \;
    

    And a POSIX version:

    find . -type f -exec sh -c 'printf "%s\n" "g/a/s//b/g" w | ed -s "$1"' _ {} \;
    

    The main reason to use ed over sed -i is that ed edits files while sed -i overwrites files, and that’s a problem if you happen to have links you don’t want to break.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to add a variable ${date} in the following bash script: ffmpeg -i
I am using the following command in a bash script to loop through directories
I execute the following bash script: #!/bin/bash version=$1 echo $version sed 's/\${version.number}/$version/' template.txt >
I want to run the following bash command in Python 3: ls -l I
I need to simulate the following bash commands using C under Linux (with fork,
I found the following bash statement in a tutorial: edit ~/.bash_profile When I run
I'm attempting to execute the following bash command on some images using Ruby: class
I'm trying to convert the following bash code into C++ using boost::iostreams: #!/usr/bin/bash (
I just installed rvm in my machine using the following command bash < <(curl
I use the following Bash Shell script to list the .txt files recursively under

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.