-
-
Save daydreamboy/0fa70fb6608f7bb4cce0463cbef9ee06 to your computer and use it in GitHub Desktop.
Revisions
-
magnetikonline revised this gist
Aug 19, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -73,5 +73,5 @@ ## Reference - http://tldp.org/LDP/abs/html/string-manipulation.html. - http://tldp.org/LDP/abs/html/parameter-substitution.html. - http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_02. -
magnetikonline revised this gist
Apr 8, 2016 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -65,6 +65,10 @@ <td>Extract <code>length</code> characters from <code>variable</code> starting at <code>position</code></td> <td><code>${variable:position:length}</code></td> </tr> <tr> <td>String length of <code>variable</code></td> <td><code>${#variable}</code></td> </tr> </table> ## Reference -
magnetikonline revised this gist
Feb 22, 2016 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -43,11 +43,11 @@ <th colspan="2">Substitution</th> </tr> <tr> <td>If <code>variable</code> not set, return <code>value</code>, else <code>variable</code></td> <td><code>${variable-value}</code></td> </tr> <tr> <td>If <code>variable</code> not set <em>or</em> empty, return <code>value</code>, else <code>variable</code></td> <td><code>${variable:-value}</code></td> </tr> <tr> -
magnetikonline revised this gist
Feb 22, 2016 . 1 changed file with 9 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -47,9 +47,17 @@ <td><code>${variable-value}</code></td> </tr> <tr> <td>If <code>variable</code> not set <em>or</em> empty, return <code>value</code></td> <td><code>${variable:-value}</code></td> </tr> <tr> <td>If <code>variable</code> set, return <code>value</code>, else null string</td> <td><code>${variable+value}</code></td> </tr> <tr> <td>If <code>variable</code> set <em>and</em> not empty, return <code>value</code>, else null string</td> <td><code>${variable:+value}</code></td> </tr> <tr> <th colspan="2">Extraction</th> </tr> -
magnetikonline revised this gist
Oct 22, 2015 . 1 changed file with 7 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -50,6 +50,13 @@ <td>If <code>variable</code> set, return <code>value</code>, else return null string</td> <td><code>${variable+value}</code></td> </tr> <tr> <th colspan="2">Extraction</th> </tr> <tr> <td>Extract <code>length</code> characters from <code>variable</code> starting at <code>position</code></td> <td><code>${variable:position:length}</code></td> </tr> </table> ## Reference -
magnetikonline revised this gist
Oct 15, 2015 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -43,11 +43,11 @@ <th colspan="2">Substitution</th> </tr> <tr> <td>If <code>variable</code> not set, return <code>value</code></td> <td><code>${variable-value}</code></td> </tr> <tr> <td>If <code>variable</code> set, return <code>value</code>, else return null string</td> <td><code>${variable+value}</code></td> </tr> </table> -
magnetikonline revised this gist
Oct 15, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -48,7 +48,7 @@ </tr> <tr> <td>If <code>variable</code> set, use <code>value</code>, else use null string</td> <td><code>${variable+value}</code></td> </tr> </table> -
magnetikonline revised this gist
Oct 15, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -55,4 +55,4 @@ ## Reference - http://tldp.org/LDP/abs/html/string-manipulation.html. - http://www.tldp.org/LDP/abs/html/parameter-substitution.html. - http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_02. -
magnetikonline created this gist
Sep 15, 2015 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,58 @@ # Bash string manipulation cheatsheet <table> <tr> <th colspan="2">Removal</th> </tr> <tr> <td>Delete shortest match of <code>needle</code> from front of <code>haystack</code></td> <td><code>${haystack#needle}</code></td> </tr> <tr> <td>Delete longest match of <code>needle</code> from front of <code>haystack</code></td> <td><code>${haystack##needle}</code></td> </tr> <tr> <td>Delete shortest match of <code>needle</code> from back of <code>haystack</code></td> <td><code>${haystack%needle}</code></td> </tr> <tr> <td>Delete longest match of <code>needle</code> from back of <code>haystack</code></td> <td><code>${haystack%%needle}</code></td> </tr> <tr> <th colspan="2">Replacement</th> </tr> <tr> <td>Replace first match of <code>needle</code> with <code>replacement</code> from <code>haystack</code></td> <td><code>${haystack/needle/replacement}</code></td> </tr> <tr> <td>Replace all matches of <code>needle</code> with <code>replacement</code> from <code>haystack</code></td> <td><code>${haystack//needle/replacement}</code></td> </tr> <tr> <td>If <code>needle</code> matches front of <code>haystack</code> replace with <code>replacement</code></td> <td><code>${haystack/#needle/replacement}</code></td> </tr> <tr> <td>If <code>needle</code> matches back of <code>haystack</code> replace with <code>replacement</code></td> <td><code>${haystack/%needle/replacement}</code></td> </tr> <tr> <th colspan="2">Substitution</th> </tr> <tr> <td>If <code>variable</code> not set, use <code>fallback</code></td> <td><code>${variable-fallback}</code></td> </tr> <tr> <td>If <code>variable</code> set, use <code>value</code>, else use null string</td> <td><code>${variable-value}</code></td> </tr> </table> ## Reference - http://tldp.org/LDP/abs/html/string-manipulation.html. - http://www.tldp.org/LDP/abs/html/parameter-substitution.html. - http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_02