Skip to content

Instantly share code, notes, and snippets.

@IDK9911
Last active January 9, 2023 11:16
Show Gist options
  • Save IDK9911/4fee5cc27c0cf00a696b0085fb2312bc to your computer and use it in GitHub Desktop.
Save IDK9911/4fee5cc27c0cf00a696b0085fb2312bc to your computer and use it in GitHub Desktop.
To convert a csv file with the format of (e.g: master> git branch <branchname> INTO master> git branch branchname
% sed -n 's!<\([a-z]*\)>!\1!g;p' git_shortcuts.csv > git_final shortcut. exercises Mon 9
Here ! is used instead of foward slash(/)
you have to escape paranthesis. Kinda confused on that one.
\1 is used to extract what's inside the () 1st paranthesis.
Another e.g:
sed -n 's!<\([a-z]*\)>!\1!g;p' << EOF
heredoc> <sahil> <kazim>
heredoc> EOF
sahil kazim
Here i have used input redirection.
Basically it will extract whats inside the <> and prints that and g tells for every element.
Other subsituition flags are:
i- ignore case
p-print
g:for all
2:just for second item that match the pattern for that substitute.
w: write
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment