Processing Text with Linux Shell - Part 1 Shamil on July 27, 2018 Into the world of sed If you are using any *nix systems on a daily basis, chances are you are already familiar with, or at least you hav... Read full post Submit Preview Dismiss Collapse Expand Rémi Lavedrine Rémi Lavedrine Rémi Lavedrine Follow Software Dev turned Security Dev. Follow me on dev.to, twitch.tv/shostarsson or wildnsecure.com Work Head of Security Joined Aug 2, 2018 • Aug 8 '18 Dropdown menu Copy link Hide Good guide. I love using sed for modifying text. It is very useful for Security testing to modify files very quickly. You must definitely learn how to use sed and grep commands. It will save you a lot of times. Collapse Expand kip kip kip Follow 404 bio not found ... yet Joined Jan 25, 2018 • Jul 28 '18 Dropdown menu Copy link Hide Good guide! Collapse Expand p-mcgowan p-mcgowan p-mcgowan Follow 418 bio is a teapot Joined Oct 2, 2017 • Jul 28 '18 Dropdown menu Copy link Hide IIRC on mac sed -i behaves differently - The default is not GNU sed. I believe you can brew it to get the good one Collapse Expand Shamil Shamil Shamil Follow Caffeine junkie with a soft spot for cosmology. Location India Education Bachelor of Technology Work Senior Software Engineer Joined Mar 12, 2017 • Jul 29 '18 Dropdown menu Copy link Hide Hi. I have never used any mac. Would you kindly provide details of sed -i behavior so I can update this article accordingly? Collapse Expand Ben Sinclair Ben Sinclair Ben Sinclair Follow I'm an ex-sysadmin from the late 20th century. These days I do more software architecture and whatnot, and promote UX and accessibility. Location Scotland Education Something something cybernetics Pronouns They/them Work General-purpose software person Joined Aug 29, 2017 • Jul 30 '18 • Edited on Jul 30 • Edited Dropdown menu Copy link Hide BSD sed expects -i to take a file extension so it can save a backup. Instead of using this: sed -i YOUR_COMMANDS_HERE foo.txt you can use something like the following, which will make a backup file and then immediately delete it if the command succeeded: sed -i.bak YOUR_COMMANDS_HERE -- foo.txt && rm -- "foo.txt.bak" That looks a little nasty, but it's portable; GNU sed's -i also takes a file extension as an optional argument. Collapse Expand Mathieu PATUREL Mathieu PATUREL Mathieu PATUREL Follow Don't have much inspiration for an original bio right now... Email australie.p@gmail.com Location Australia Education self taught Joined Apr 23, 2017 • Jul 28 '18 Dropdown menu Copy link Hide sed -i.bak '12,30d' file_name this is a very nice trick! Thanks! Collapse Expand kip kip kip Follow 404 bio not found ... yet Joined Jan 25, 2018 • Jul 28 '18 • Edited on Jul 28 • Edited Dropdown menu Copy link Hide If you ever use vi / vim, this command also works and other commands too. Collapse Expand sotondolphin sotondolphin sotondolphin Follow Joined Jul 29, 2018 • Jul 29 '18 Dropdown menu Copy link Hide nice article. many tricks learnt Collapse Expand Andrey Ramnikov Andrey Ramnikov Andrey Ramnikov Follow Location Frankfurt Work DevOps at Reply Joined Dec 30, 2019 • Feb 7 '20 Dropdown menu Copy link Hide Very nice tutorial. Collapse Expand Will Will Will Follow I quit a music phd. Now I'm developing and acting as a backup administrator. Joined Aug 15, 2017 • Jul 31 '18 Dropdown menu Copy link Hide Great post! I love to use this funky site for more fun with sed: grymoire.com/Unix/Sed.html Code of Conduct • Report abuse
Good guide.
I love using sed for modifying text. It is very useful for Security testing to modify files very quickly.
You must definitely learn how to use sed and grep commands.
It will save you a lot of times.
Good guide!
IIRC on mac
sed -ibehaves differently - The default is not GNU sed. I believe you canbrewit to get the good oneHi. I have never used any mac. Would you kindly provide details of
sed -ibehavior so I can update this article accordingly?BSD sed expects
-ito take a file extension so it can save a backup.Instead of using this:
you can use something like the following, which will make a backup file and then immediately delete it if the command succeeded:
That looks a little nasty, but it's portable; GNU sed's
-ialso takes a file extension as an optional argument.this is a very nice trick! Thanks!
If you ever use vi / vim, this command also works and other commands too.
nice article. many tricks learnt
Very nice tutorial.
Great post!
I love to use this funky site for more fun with sed: grymoire.com/Unix/Sed.html