Package: pysed
Table of Contents:AboutInstallationCommand Line Tool UsageRegex flagsUsage ExamplesCopyrightAboutPysed is a stream editor, is used to perform basic text transformations
from a file or from pipeline. It reads text, line by line, from a file
and replace, insert or print all text or specific area.Installation$pipinstallpysed--upgradeuninstall$pipuninstallpysedCommand Line Tool UsageUsage:pysed[OPTION]{patt}{repl}{lines/max/flag}[[input-file],--write]pysedisutilitythatparsesandtransformstextOptionalarguments:-h,--helpPrintthishelpmessageandexit-v,--versionPrintprogramversionandexit-r,--replaceSearchandreplacetext-f,--findallFindallfrompatternintext-s,--searchSearchforthefirstmatching-m,--matchPatternmatchinginthebeginning-l,--linesSearchpatternandprintlines-g,--highlightHighlightandprinttext-t,--statPrinttextstatistics--writeWritechangestofileRegex flagsSyntaxPython syntax,   MeaningI or IGNORECASEre.IGNORECASE,   ignore case.M or MULTILINEre.MULTILINE,    make begin/end {^, $} consider each line.S or DOTALLre.DOTALL,       make . match newline too.U or UNICODEre.UNICODE,      make {w, W, b, B} follow Unicode rules.L or LOCALEre.LOCALE,       make {w, W, b, B} follow locale.X or VERBOSEre.VERBOSE,      allow comment in regex.Usage Examples$cattext.txtThisismycat,whosenameisBetty.Thisismydog,whosenameisFrank.Thisismyfish,whosenameisGeorge.Thisismygoat,whosenameisAdam.Replacetext:$pysed-r"name""surname"text.txtThisismycat,whosesurnameisBetty.Thisismydog,whosesurnameisFrank.Thisismyfish,whosesurnameisGeorge.Thisismygoat,whosesurnameisAdam.Replacetextinspecificlines:$pysed-r"name""surname"2,4text.txtThisismycat,whosesurnameisBetty.Thisismydog,whosesurnameisFrank.Thisismyfish,whosenameisGeorge.Thisismygoat,whosenameisAdam.Replacetextinspecificlinesandmax:$pysed-r"is""IS"1,7/1text.txtThISismycat,whosesurnameisBetty.Thisismydog,whosesurnameisFrank.Thisismyfish,whosenameisGeorge.ThISismygoat,whosenameisAdam.Addcharactertothebeginningofeachline:$pysed-r"^""# "text.txt# This is my cat,
#  whose name is Betty.
# This is my dog,
#  whose name is Frank.
# This is my fish,
#  whose name is George.
# This is my goat,
#  whose name is Adam.Addcharactertotheendofeachline:$pysed-r"$"" #"text.txtThisismycat,#whosenameisBetty.#Thisismydog,#whosenameisFrank.#Thisismyfish,#whosenameisGeorge.#Thisismygoat,#whosenameisAdam.#Findallmatchingpattern:$pysed-f"name "text.txtnamenamenamenameFindallmatchingpatterninspecificlines:$pysed-f"name """2,4text.txtnamenameSearchandprintlines:$pysed-l"name"text.txt-Thisismycat,2whosenameisBetty.-Thisismydog,4whosenameisFrank.-Thisismyfish,6whosenameisGeorge.-Thisismygoat,8whosenameisAdam.Highlighttext:$pysed-g"name""red"text.txtThisismycat,whosenameisBetty.Thisismydog,whosenameisFrank.Thisismyfish,whosenameisGeorge.Thisismygoat,whosenameisAdam.Printstaticstext:$pysed-ttext.txtLines:8,Words:32,Chars:125,Blanks:27Usetheargument"--write"inanycasewhenyouwanttosavethechanges:$pysed-r"name""surname"text.txt--writeUseaspiping:$echo"This is my cat, whose name is Betty"|pysed-r"cat""dog"Thisismydog,whosenameisBetty$repl="fish"$echo"This is my cat, whose name is Betty"|pysed-r"cat"$replThisismyfish,whosenameisBetty$echo"This is my cat, whose name is Betty"|pysed-r"[^\W]+""-"----,----$echo"This is my cat, whose name is Betty"|pysed-r"is""IS"1/1ThISismycat,whosenameisBetty$echo"910a13de57dfbdf6f06675db975f8407"|pysed-r"[^\d+]"91013576066759758407$echo"910a13de57dfbdf6f06675db975f8407"|pysed-f"\d+"91013576066759758407$echo"910a13de57dfbdf6f06675db975f8407"|pysed-s"\d+"910$echo"910a13de57dfbdf6f06675db975f8407"|pysed-s"(\d+)(\w+)"""0/1910$echo"910a13de57dfbdf6f06675db975f8407"|pysed-s"(\d+)(\w+)"""0/2a13de57dfbdf6f06675db975f8407$echo"The temperature today is at +12 degrees Celsius"|pysed-s".\d+"+12$echo"/usr/local/bin"|pysed-r"/local"""/usr/bin$echo"/usr/local/bin"|pysed-r"/LoCal"""//IGNORECASE/usr/binUsewithcommand"find".Youcanuse"find"and"pysed"commandsincombinationtofindandreplacetextinmultiplefiles.Forexample:$find.-name*.py-execpysed-r"lefttext""righttext"{}--write\;thiscommandfinds'lefttext'stringinallpythonfilesandreplaceitwith'righttext'.Please reportIssuesCopyrightCopyright © Dimitris ZlatanidisLinux is a Registered Trademark of Linus Torvalds.