Questions tagged [ed]

ed is a line-oriented text editor for Unix. Use this tag for questions related to ed scripting; questions about interactive usage are considered off-topic.

ed was created in 1969 by Ken Thompson as a simplified successor to the QED editor and was part of the first version of Unix. It is still part of the POSIX standard.

Unlike visual ("full-screen") editors such as vi/vim, ed is a line editor. It pioneered and influenced many features seen in popular tools such as grep, sed, ex, and vi/vim.

ed commands can be stored in scripts; notably, the diff tool can be set to generate ed commands when using the -e command line option.

Questions about scripting with ed are likely to be suitable for Stack Overflow; questions about interactive usage might be better suited for Unix & Linux or Super User.

References

66 questions
0
votes
0 answers

Echo in bash is replacing first letter/character with the last when pulling from array

I made a simple script in bash that asks "What would you like to $action?". The action variable should be replaced with user's choice on each loop. This seems to work, but the issue is that the last character which is the question mark (?) is…
0
votes
1 answer

Is there a way to append text to a text file starting with two line breaks from the command line

I am on FreeBSD 13 using csh and I have a notes.txt file which I would like to be able to append notes to, quickly, from the command line. I would like to be able to add two 'new lines' before each note that I append, in order to separate the notes,…
Jon Stier
  • 1
  • 1
0
votes
2 answers

crontab with ed by commands on stream, results in "no modification made"

I am trying to append a line to my crontab file. I know there are other ways to work around this problem, but still want to know what caused it. The command is run on raspberry pi 3 B+, raspbian lite is installed, with GNU ed 1.15, cron…
bivoje
  • 23
  • 1
  • 7
0
votes
1 answer

Enter lines at beginning and end of file in bash with variables

i am creating a script that will take a csv file and make an XML file. The script will also take user entered data to go in the xml as well. I have created a script that will make my XML, but i am having problems entering my read in variable at the…
Red_badger
  • 119
  • 1
  • 15
0
votes
1 answer

Django Filters with Rest Framework Authentication message filtering strategy/issue in a Chat application

I have a Django DRF backend, with token user authentication implemented. The application itself is a chat which consists of public Lobbies and private Threads (Threads between particular users). Currently my models file includes Message model which…
0
votes
1 answer

ed is not working when looping through file- shell scriping

#!/bin/bash filename='urls.txt' old_url="test" while read line do new_url=$line echo "New URL is "$new_url echo -e '%s/'"$new_url"'/'"$old_url"'/g\nw' |ed ca-sample.conf old_url=$new_url echo "" echo "Old URL is "$old_url sleep…
Master
  • 19
  • 1
0
votes
1 answer

ed pattern - the first chars in line is unknown

This is how I am adding text before first pattern reveal: FILE_NAME="folder/myfile.c++" STR_TO_ADD="string that i want to add" PATTERN="banana" ed $FILE_NAME 2>NULL 1>NULL<
Ita
  • 1
  • 1
0
votes
2 answers

How to add text after last pattern match using ed

This is how I am adding text before first pattern, I want to add after last pattern FILE_NAME="folder/myfile.c++" STR_TO_ADD="string that i want to add" PATTERN="banana" ed $FILE_NAME 2>NULL…
Ita
  • 1
  • 1
0
votes
2 answers

How to use xargs with ed?

I want to batch replace strings recursively inside a folder, and I have settled with using Perl. I would like to see if there is a solution which requires less dependency and work across platforms. For listing files, I can use anything from ls to…
Sunny Pun
  • 726
  • 5
  • 14
0
votes
4 answers

Using gawk to Replace a Pattern of Text with the Contents of a File Whose Filename is Inside the Text

I am trying to replace text inside a text file according to a certain criteria. For example, if I have three text files, with outer.txt containing: Blah Blah Blah INCLUDE inner1.txt Etcetera Etcetera INCLUDE inner2.txt end of…
gawk_Nube
  • 3
  • 1
0
votes
1 answer

Invert the 'ed' command for reverting back to previous file version

I am doing a version control project in Unix using bash script. How can I move from the current version to a previous version without having to build a new file from scratch to the required version. Is there a way to invert the ed scripts to move…
Shiv SMK
  • 3
  • 2
0
votes
1 answer

Replace characters on specific location every line

We got an exercise where we have to do certain things with the following text document: Rank|Mountain|Height (m)|Height (ft)|Prominence (m)|Range|Coordinates|Parent mountain|First ascent|Ascents (failed attempts)|Country 1|Mount…
0
votes
3 answers

Swap two blocks of text programatically

I have an XML file made up of multiple blocks that are very similar. Here are two:
Joey Dumont
  • 898
  • 2
  • 7
  • 25
0
votes
2 answers

How to delete lines between two search-matches using ed line editor

I have a text file I am editing (in my case a JMeter XML) and I use ed to find two lines that mark the 1st and last lines of a XML section. How can I delete the lines between the two search matches? example file: 1 2
RaamEE
  • 3,017
  • 4
  • 33
  • 53
0
votes
2 answers

Replace specific tags in xml in unix

I would like to replace specific values (Not for all elements). Here all are having same Background_color, but i do not want to replace Background_color for only specific one. How can we implement? This is just a sample code.(I would have list of…