8000 GitHub · Where software is built 8000
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Sed text processing and stream editor #1
Open
@MakerGYT

Description

@MakerGYT

Basic

Replace

sed -i 's/before/after/' file

Execute multiple commands in the same line

sed -i -e '' -e '' file

Value

sed -i 's/'$value'/after/' file 

Save

sed -i 's/abc\(def\)/ghi/' file # ghidef
sed -i 's/abc\(def\)/\1/' file # defdef
sed -i 's/abc.*/[&]/' file # [abc.*] 

Delete

sed -i '1,$d' file # remove 1-end line
sed -i 's/abc//' file # delete all abc

Note

  • Special matching characters need to be escaped

Question

  • Cannot execute when the variable contains special characters

Refrence

Metadata

Metadata

Assignees

No one assigned

    Labels

    linuxOperating skills and system analysis

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0