Last active
January 9, 2023 11:16
-
-
Save kazimmsyed/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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% sed -n 's!<\([a-z]*\)>!\1!g;p' git_shortcuts.csv > git_final shortcut. exercises Mon 9 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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