Command Line macOS ed Line Editor Primer Tutorial

Command Line macOS ed Line Editor Primer Tutorial

Command Line macOS ed Line Editor Primer Tutorial

All these years later, after lots of days early on in this when it was the only way (like, who can forget DOS edlin masochistic creativity?!), I get a kick out of command line “line editor” usage that is self contained. Today’s work is with the macOS (and Linux and unix) command line “ed” line text editor. And, yes, there is the piped solution idea of using “sed”. Yes, that is good too, but with “ed” it is not only …

  • an excellent and simple global replacement … eg. …

    ,s/old/new/g

    … set up … but adding to its “self containment”, and like with another “vi” (Linux or unix or macOS) text editor (favourite of ours) you can use with “ed” those …
  • w [new file, or not]
    … to write contents into a [new file]
  • q
    … to quit back to the command line

… facilities meaning an “ed” command like …


ed find_images_via_size00000__1.txt < edin.txt

… will …

… turn find_images_via_size00000__1.txt … … via edin.txt …

… into find_images_via_size00000__1.xxx …
1620 x 2160 ./IMG_0838.jpg
1620 x 2160 ./IMG_0839.jpg
1620 x 2160 ./IMG_0840.jpg
1620 x 2160 ./IMG_0841.jpg
1620 x 2160 ./IMG_0843.jpg
750 x 1334 ./IMG_1530.jpg
750 x 1334 ./IMG_1531.jpg
1440 x 900 ./abn_look-1.jpg
1440 x 900 ./abn_look-2.jpg
1440 x 900 ./abn_look-3.jpg
1440 x 900 ./abn_look-4.jpg
1440 x 900 ./airdrop_revisited_declined_everyone_fixes.jpg
,s/IMG/New abn/g
,s/abn/neW Abn/g
,s/airdrop/nEw/g
w find_images_via_size00000__1.xxx
q
1620 x 2160 ./New neW Abn_0838.jpg
1620 x 2160 ./New neW Abn_0839.jpg
1620 x 2160 ./New neW Abn_0840.jpg
1620 x 2160 ./New neW Abn_0841.jpg
1620 x 2160 ./New neW Abn_0843.jpg
750 x 1334 ./New neW Abn_1530.jpg
750 x 1334 ./New neW Abn_1531.jpg
1440 x 900 ./neW Abn_look-1.jpg
1440 x 900 ./neW Abn_look-2.jpg
1440 x 900 ./neW Abn_look-3.jpg
1440 x 900 ./neW Abn_look-4.jpg
1440 x 900 ./nEw_revisited_declined_everyone_fixes.jpg

as seen with today’s tutorial picture.

If this was interesting you may be interested in this too.

This entry was posted in eLearning, Operating System, Tutorials and tagged , , , , , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *