Re: Looking for a multiple editor

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Tim here.  You can make batch-changes to files with sed, ed, or
vi/vim (and likely many others, but those are the ones I use).

You don't detail what sorts of changes you need to make, so it's hard
to provide a more complete solution, but some examples:

- if you want to just do a word-substitution through all of your
  files like changing "John" to "Tim", you can use

   sed -i.bak 's/John/Tim/g' *.txt

  Note that it might over-reach changing things like "Johnson" to
  "Timson"

- if you want to move a line *down* in a file, you can also use sed,
  but if you have multiple manipulations (or want to move things
  *up* in a file) you want to execute, you want to reach for one of
  the others I listed.  E.g. if you want to move all the lines from
  the last line containing "Chapter" through the end of the file up
  to the top of your file, you can do it with

   for f in *.txt; do printf '1\n?Chapter?,$m0\nwq\n' | ed -s "$f" ; done

  which goes to the first line in each file, searches backwards for
  "Chapter", then from there through the end of the file ("$"), moves
  ("m") those lines to the beginning of the file (after line 0)

- if your changes are more complex, vim has some very powerful tools
  for manipulating and scripting across all the files you open with
  it,  using the ":bufdo" or ":argdo" command.

I do these sorts of edits all the time, so if you have more details
on the sorts of changes you want to make, I can gladly whip up some
more usable answer.

-tim



On March 30, 2022, Linux for blind general discussion wrote:
> I have a number of texts in which I wish to make alterations that
> are the same for all of them. I think that there is a linux program
> in which I can list the alterations and them have them made. but I
> can't remember what it is called. Please refresh my memory.
> 
> thanks,
> John
> 
> -- 
> John J. Boyer
> Email: john.boyer@xxxxxxxxxxxxxxxxx
> website: http://www.abilitiessoft.org
> Status: Company dissolved but website and email addresses  live.
> Location: Madison, Wisconsin, USA
> Mission: developing assistive technology software and providing
> STEM services that are available at no cost
> 
> 
> _______________________________________________
> Blinux-list mailing list
> Blinux-list@xxxxxxxxxx
> https://listman.redhat.com/mailman/listinfo/blinux-list
> 

_______________________________________________
Blinux-list mailing list
Blinux-list@xxxxxxxxxx
https://listman.redhat.com/mailman/listinfo/blinux-list




[Index of Archives]     [Linux Speakup]     [Fedora]     [Linux Kernel]     [Yosemite News]     [Big List of Linux Books]