diff options
author | garhve <git@garhve.com> | 2023-01-02 06:02:01 +0800 |
---|---|---|
committer | garhve <git@garhve.com> | 2023-01-02 06:02:01 +0800 |
commit | be772f40c42711de54a3331db2781b1511acba9d (patch) | |
tree | 0808a7750d3c1055b0e86071c219d872775b1f92 /posts/3/index.html | |
parent | 3ae5ecf803ed2d4ece2c9da6d91aae0f075c5b0c (diff) |
change to zola
Diffstat (limited to 'posts/3/index.html')
-rw-r--r-- | posts/3/index.html | 282 |
1 files changed, 0 insertions, 282 deletions
diff --git a/posts/3/index.html b/posts/3/index.html deleted file mode 100644 index 7608da9..0000000 --- a/posts/3/index.html +++ /dev/null @@ -1,282 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="utf-8" /> - <meta name="generator" content="Hugo 0.108.0"> - - <meta http-equiv="X-UA-Compatible" content="IE=edge" /> - <meta name="viewport" content="width=device-width, initial-scale=1" /> - <meta name="author" content="garhve" /> - <meta property="og:url" content="https://blog.garhve.com/posts/3/" /> - <link rel="canonical" href="https://blog.garhve.com/posts/3/" /><link rel="apple-touch-icon" href="https://assets.garhve.com/pictures/assets/images/favicon/favicon.ico" /> - <link rel="icon" href="https://assets.garhve.com/pictures/assets/images/favicon/favicon.ico" /> - <link rel="shortcut" href="https://assets.garhve.com/pictures/assets/images/favicon/favicon.ico" /><link rel="alternate" type="application/atom+xml" href="https://blog.garhve.comindex.xml" title="blog | garhve's hub"> - - <script type="application/ld+json"> - { - "@context" : "http://schema.org", - "@type" : "BlogPosting", - "mainEntityOfPage": { - "@type": "WebPage", - "@id": "https:\/\/blog.garhve.com" - }, - "articleSection" : "posts", - "name" : "Mess with bash(1)", - "headline" : "Mess with bash(1)", - "description" : "Crontab crontab is a useful tool, I really regret that I don\u0026rsquo;t familar it earlier.\nIt\u0026rsquo;s usage really simple, and these two are my frequent using:\ncrontab -e #edit crontab file that reside in \/var\/spool\/cron crontab -l #list current crontab job It basic syntax as follow, also really simple example of usage:\ndelete file foo every minute * * * * * rm foo delete file foo every 15 minutes 15 * * * * rm foo delete file foo every beginning of hour 0 * * * * rm foo delete file foo every minute after 3 hours * 3 * * * rm foo delete file foo every day at 18:30 30 18 * * * rm foo delete file foo every beginning of month 0 0 0 * * rm foo delete file foo on beginning of 1st,10th of month 0 0 1,10 * * rm foo The usage really simple, I now use it to renew my SSL certification and daily update bt-tracker.", - "inLanguage" : "en-US", - "author" : "garhve", - "creator" : "garhve", - "publisher": "garhve", - "accountablePerson" : "garhve", - "copyrightHolder" : "garhve", - "copyrightYear" : "2022", - "datePublished": "2022-08-25 13:40:56 \u002b0800 CST", - "dateModified" : "2022-08-25 13:40:56 \u002b0800 CST", - "url" : "https:\/\/blog.garhve.com\/posts\/3\/", - "keywords" : [ ] - } -</script> -<title>Mess with bash(1)</title> - <meta property="og:title" content="Mess with bash(1)" /> - <meta property="og:type" content="article" /> - <meta property="og:description" content="Crontab crontab is a useful tool, I really regret that I don&rsquo;t familar it earlier. -It&rsquo;s usage really simple, and these two are my frequent using: -crontab -e #edit crontab file that reside in /var/spool/cron crontab -l #list current crontab job It basic syntax as follow, also really simple example of usage: -delete file foo every minute * * * * * rm foo delete file foo every 15 minutes 15 * * * * rm foo delete file foo every beginning of hour 0 * * * * rm foo delete file foo every minute after 3 hours * 3 * * * rm foo delete file foo every day at 18:30 30 18 * * * rm foo delete file foo every beginning of month 0 0 0 * * rm foo delete file foo on beginning of 1st,10th of month 0 0 1,10 * * rm foo The usage really simple, I now use it to renew my SSL certification and daily update bt-tracker." /> - <meta name="description" content="Crontab crontab is a useful tool, I really regret that I don&rsquo;t familar it earlier. -It&rsquo;s usage really simple, and these two are my frequent using: -crontab -e #edit crontab file that reside in /var/spool/cron crontab -l #list current crontab job It basic syntax as follow, also really simple example of usage: -delete file foo every minute * * * * * rm foo delete file foo every 15 minutes 15 * * * * rm foo delete file foo every beginning of hour 0 * * * * rm foo delete file foo every minute after 3 hours * 3 * * * rm foo delete file foo every day at 18:30 30 18 * * * rm foo delete file foo every beginning of month 0 0 0 * * rm foo delete file foo on beginning of 1st,10th of month 0 0 1,10 * * rm foo The usage really simple, I now use it to renew my SSL certification and daily update bt-tracker." /> - <meta property="og:locale" content="en-us" /><meta property="og:image" content="https://assets.garhve.com/pictures/assets/images/favicon/favicon.ico" /> - - - - - <style>@font-face{font-family:huanzi;src:url(/fonts/huanzi.woff2)format('woff2')}@font-face{font-family:fira code;src:url(/fonts/FiraCode-Regular.woff2)format('woff2')}body{font-family:bree serif,huanzi,sans-serif;-webkit-font-smoothing:antialiased;margin:0 20px}article{max-width:800px;margin-left:auto;margin-right:auto}a{color:#000;text-decoration:none}a:hover{font-weight:600;text-decoration:underline}.post-ads{margin:50px 0}.markdown-body{font-size:18px;max-width:100%}.markdown-body a{text-decoration:underline;text-decoration-color:#000}.markdown-body blockquote{margin:0;padding:0 1em;color:#57606a;border-left:.25em solid #d0d7de}.markdown-body pre{padding:16px;overflow:auto;border-radius:10px}.markdown-body code{padding:.2em .4em;font-size:80%;background-color:inherit;border-radius:6px;font-family:fira code,monospace}code{text-size-adjust:100%;-ms-text-size-adjust:100%;-moz-text-size-adjust:100%;-webkit-text-size-adjust:100%}table{width:100%}.markdown-body pre>code{padding:0;font-size:70%;background-color:inherit;border:0;font-family:fira code,monospace}.Chinese .markdown-body{line-height:200%}.site-date-catalog{font-size:2rem}.header-title{font-size:2rem;font-weight:700;margin-top:32px;font-family:bungee shade,sans-serif}.header-title a{text-decoration:none}.header-subtitle{color:#666}.header-items{margin:10px 0}.header-item{margin:0 5px}.header-line{width:100%;border-width:2px;border-color:#482936;border-style:solid none none none}.lang-switch{font-weight:600}#posts-list{min-height:600px}.posts-line{font-size:1.2rem;margin:12px 0}.posts-categories{font-size:.8rem;margin:auto;text-align:center}.posts-category{padding:3px 0;border:#000 2px solid;border-radius:5px}.site-footer{margin-top:50px}.site-footer-item{margin-right:12px}.post-content img{max-width:100%;display:block;margin-right:auto;margin-top:12px}.post-header{margin-bottom:50px}.post-title{font-size:2rem;font-weight:600}.post-tags{display:inline;font-weight:600;padding:2px 5px;margin-right:6px;border:#000 2px solid;border-radius:5px}.post-date{font-weight:800;font-style:italic}.post-author{float:right;font-weight:600}.page-content{min-height:60%}.post-content{margin-bottom:50px}.post-content p{hyphens:auto;line-height:1.8;text-justify:ideographic;margin-bottom:1em}.related-content{border-width:3px;border-style:solid;border-color:#000;padding:0 10px;margin-bottom:50px;margin-top:100px}.related-content li{margin:5px 0}.taxonomy-term{font-size:3rem}.gallery-img{text-align:center}.gallery-img span{text-align:center}.gallery-img-desc{font-size:.8em;font-weight:800}#disqus_thread{position:relative}#disqus_thread:after{content:"";display:block;height:55px;width:100%;position:absolute;bottom:0;background:#fff}@media screen and (max-width:600px){.header-title,.header-subtitle,.header-items{text-align:center}.posts-line{font-size:16px}.markdown-body{font-size:16px}.post-title{font-size:2rem}.post-content p{letter-spacing:.05em}}@media screen and (max-width:48em){.posts-category{display:none}}</style> - - - <style>.container,.container-fluid{margin-right:auto;margin-left:auto}.container-fluid{padding-right:2rem;padding-left:2rem}.row{box-sizing:border-box;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-flex:0;-ms-flex:0 1 auto;flex:initial;-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-direction:row;flex-direction:row;-ms-flex-wrap:wrap;flex-wrap:wrap;margin-right:-.5rem;margin-left:-.5rem}.row.reverse{-webkit-box-orient:horizontal;-webkit-box-direction:reverse;-ms-flex-direction:row-reverse;flex-direction:row-reverse}.col.reverse{-webkit-box-orient:vertical;-webkit-box-direction:reverse;-ms-flex-direction:column-reverse;flex-direction:column-reverse}.col-xs,.col-xs-1,.col-xs-10,.col-xs-11,.col-xs-12,.col-xs-2,.col-xs-3,.col-xs-4,.col-xs-5,.col-xs-6,.col-xs-7,.col-xs-8,.col-xs-9,.col-xs-offset-0,.col-xs-offset-1,.col-xs-offset-10,.col-xs-offset-11,.col-xs-offset-12,.col-xs-offset-2,.col-xs-offset-3,.col-xs-offset-4,.col-xs-offset-5,.col-xs-offset-6,.col-xs-offset-7,.col-xs-offset-8,.col-xs-offset-9{box-sizing:border-box;-webkit-box-flex:0;-ms-flex:0 0 auto;flex:none;padding-right:.5rem;padding-left:.5rem}.col-xs{-webkit-box-flex:1;-ms-flex-positive:1;flex-grow:1;-ms-flex-preferred-size:0;flex-basis:0;max-width:100%}.col-xs-1{-ms-flex-preferred-size:8.33333333%;flex-basis:8.33333333%;max-width:8.33333333%}.col-xs-2{-ms-flex-preferred-size:16.66666667%;flex-basis:16.66666667%;max-width:16.66666667%}.col-xs-3{-ms-flex-preferred-size:25%;flex-basis:25%;max-width:25%}.col-xs-4{-ms-flex-preferred-size:33.33333333%;flex-basis:33.33333333%;max-width:33.33333333%}.col-xs-5{-ms-flex-preferred-size:41.66666667%;flex-basis:41.66666667%;max-width:41.66666667%}.col-xs-6{-ms-flex-preferred-size:50%;flex-basis:50%;max-width:50%}.col-xs-7{-ms-flex-preferred-size:58.33333333%;flex-basis:58.33333333%;max-width:58.33333333%}.col-xs-8{-ms-flex-preferred-size:66.66666667%;flex-basis:66.66666667%;max-width:66.66666667%}.col-xs-9{-ms-flex-preferred-size:75%;flex-basis:75%;max-width:75%}.col-xs-10{-ms-flex-preferred-size:83.33333333%;flex-basis:83.33333333%;max-width:83.33333333%}.col-xs-11{-ms-flex-preferred-size:91.66666667%;flex-basis:91.66666667%;max-width:91.66666667%}.col-xs-12{-ms-flex-preferred-size:100%;flex-basis:100%;max-width:100%}.col-xs-offset-0{margin-left:0}.col-xs-offset-1{margin-left:8.33333333%}.col-xs-offset-2{margin-left:16.66666667%}.col-xs-offset-3{margin-left:25%}.col-xs-offset-4{margin-left:33.33333333%}.col-xs-offset-5{margin-left:41.66666667%}.col-xs-offset-6{margin-left:50%}.col-xs-offset-7{margin-left:58.33333333%}.col-xs-offset-8{margin-left:66.66666667%}.col-xs-offset-9{margin-left:75%}.col-xs-offset-10{margin-left:83.33333333%}.col-xs-offset-11{margin-left:91.66666667%}.start-xs{-webkit-box-pack:start;-ms-flex-pack:start;justify-content:flex-start;text-align:start}.center-xs{-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;text-align:center}.end-xs{-webkit-box-pack:end;-ms-flex-pack:end;justify-content:flex-end;text-align:end}.top-xs{-webkit-box-align:start;-ms-flex-align:start;align-items:flex-start}.middle-xs{-webkit-box-align:center;-ms-flex-align:center;align-items:center}.bottom-xs{-webkit-box-align:end;-ms-flex-align:end;align-items:flex-end}.around-xs{-ms-flex-pack:distribute;justify-content:space-around}.between-xs{-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between}.first-xs{-webkit-box-ordinal-group:0;-ms-flex-order:-1;order:-1}.last-xs{-webkit-box-ordinal-group:2;-ms-flex-order:1;order:1}@media only screen and (min-width:48em){.container{width:49rem}.col-sm,.col-sm-1,.col-sm-10,.col-sm-11,.col-sm-12,.col-sm-2,.col-sm-3,.col-sm-4,.col-sm-5,.col-sm-6,.col-sm-7,.col-sm-8,.col-sm-9,.col-sm-offset-0,.col-sm-offset-1,.col-sm-offset-10,.col-sm-offset-11,.col-sm-offset-12,.col-sm-offset-2,.col-sm-offset-3,.col-sm-offset-4,.col-sm-offset-5,.col-sm-offset-6,.col-sm-offset-7,.col-sm-offset-8,.col-sm-offset-9{box-sizing:border-box;-webkit-box-flex:0;-ms-flex:0 0 auto;flex:none;padding-right:.5rem;padding-left:.5rem}.col-sm{-webkit-box-flex:1;-ms-flex-positive:1;flex-grow:1;-ms-flex-preferred-size:0;flex-basis:0;max-width:100%}.col-sm-1{-ms-flex-preferred-size:8.33333333%;flex-basis:8.33333333%;max-width:8.33333333%}.col-sm-2{-ms-flex-preferred-size:16.66666667%;flex-basis:16.66666667%;max-width:16.66666667%}.col-sm-3{-ms-flex-preferred-size:25%;flex-basis:25%;max-width:25%}.col-sm-4{-ms-flex-preferred-size:33.33333333%;flex-basis:33.33333333%;max-width:33.33333333%}.col-sm-5{-ms-flex-preferred-size:41.66666667%;flex-basis:41.66666667%;max-width:41.66666667%}.col-sm-6{-ms-flex-preferred-size:50%;flex-basis:50%;max-width:50%}.col-sm-7{-ms-flex-preferred-size:58.33333333%;flex-basis:58.33333333%;max-width:58.33333333%}.col-sm-8{-ms-flex-preferred-size:66.66666667%;flex-basis:66.66666667%;max-width:66.66666667%}.col-sm-9{-ms-flex-preferred-size:75%;flex-basis:75%;max-width:75%}.col-sm-10{-ms-flex-preferred-size:83.33333333%;flex-basis:83.33333333%;max-width:83.33333333%}.col-sm-11{-ms-flex-preferred-size:91.66666667%;flex-basis:91.66666667%;max-width:91.66666667%}.col-sm-12{-ms-flex-preferred-size:100%;flex-basis:100%;max-width:100%}.col-sm-offset-0{margin-left:0}.col-sm-offset-1{margin-left:8.33333333%}.col-sm-offset-2{margin-left:16.66666667%}.col-sm-offset-3{margin-left:25%}.col-sm-offset-4{margin-left:33.33333333%}.col-sm-offset-5{margin-left:41.66666667%}.col-sm-offset-6{margin-left:50%}.col-sm-offset-7{margin-left:58.33333333%}.col-sm-offset-8{margin-left:66.66666667%}.col-sm-offset-9{margin-left:75%}.col-sm-offset-10{margin-left:83.33333333%}.col-sm-offset-11{margin-left:91.66666667%}.start-sm{-webkit-box-pack:start;-ms-flex-pack:start;justify-content:flex-start;text-align:start}.center-sm{-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;text-align:center}.end-sm{-webkit-box-pack:end;-ms-flex-pack:end;justify-content:flex-end;text-align:end}.top-sm{-webkit-box-align:start;-ms-flex-align:start;align-items:flex-start}.middle-sm{-webkit-box-align:center;-ms-flex-align:center;align-items:center}.bottom-sm{-webkit-box-align:end;-ms-flex-align:end;align-items:flex-end}.around-sm{-ms-flex-pack:distribute;justify-content:space-around}.between-sm{-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between}.first-sm{-webkit-box-ordinal-group:0;-ms-flex-order:-1;order:-1}.last-sm{-webkit-box-ordinal-group:2;-ms-flex-order:1;order:1}}@media only screen and (min-width:64em){.container{width:65rem}.col-md,.col-md-1,.col-md-10,.col-md-11,.col-md-12,.col-md-2,.col-md-3,.col-md-4,.col-md-5,.col-md-6,.col-md-7,.col-md-8,.col-md-9,.col-md-offset-0,.col-md-offset-1,.col-md-offset-10,.col-md-offset-11,.col-md-offset-12,.col-md-offset-2,.col-md-offset-3,.col-md-offset-4,.col-md-offset-5,.col-md-offset-6,.col-md-offset-7,.col-md-offset-8,.col-md-offset-9{box-sizing:border-box;-webkit-box-flex:0;-ms-flex:0 0 auto;flex:none;padding-right:.5rem;padding-left:.5rem}.col-md{-webkit-box-flex:1;-ms-flex-positive:1;flex-grow:1;-ms-flex-preferred-size:0;flex-basis:0;max-width:100%}.col-md-1{-ms-flex-preferred-size:8.33333333%;flex-basis:8.33333333%;max-width:8.33333333%}.col-md-2{-ms-flex-preferred-size:16.66666667%;flex-basis:16.66666667%;max-width:16.66666667%}.col-md-3{-ms-flex-preferred-size:25%;flex-basis:25%;max-width:25%}.col-md-4{-ms-flex-preferred-size:33.33333333%;flex-basis:33.33333333%;max-width:33.33333333%}.col-md-5{-ms-flex-preferred-size:41.66666667%;flex-basis:41.66666667%;max-width:41.66666667%}.col-md-6{-ms-flex-preferred-size:50%;flex-basis:50%;max-width:50%}.col-md-7{-ms-flex-preferred-size:58.33333333%;flex-basis:58.33333333%;max-width:58.33333333%}.col-md-8{-ms-flex-preferred-size:66.66666667%;flex-basis:66.66666667%;max-width:66.66666667%}.col-md-9{-ms-flex-preferred-size:75%;flex-basis:75%;max-width:75%}.col-md-10{-ms-flex-preferred-size:83.33333333%;flex-basis:83.33333333%;max-width:83.33333333%}.col-md-11{-ms-flex-preferred-size:91.66666667%;flex-basis:91.66666667%;max-width:91.66666667%}.col-md-12{-ms-flex-preferred-size:100%;flex-basis:100%;max-width:100%}.col-md-offset-0{margin-left:0}.col-md-offset-1{margin-left:8.33333333%}.col-md-offset-2{margin-left:16.66666667%}.col-md-offset-3{margin-left:25%}.col-md-offset-4{margin-left:33.33333333%}.col-md-offset-5{margin-left:41.66666667%}.col-md-offset-6{margin-left:50%}.col-md-offset-7{margin-left:58.33333333%}.col-md-offset-8{margin-left:66.66666667%}.col-md-offset-9{margin-left:75%}.col-md-offset-10{margin-left:83.33333333%}.col-md-offset-11{margin-left:91.66666667%}.start-md{-webkit-box-pack:start;-ms-flex-pack:start;justify-content:flex-start;text-align:start}.center-md{-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;text-align:center}.end-md{-webkit-box-pack:end;-ms-flex-pack:end;justify-content:flex-end;text-align:end}.top-md{-webkit-box-align:start;-ms-flex-align:start;align-items:flex-start}.middle-md{-webkit-box-align:center;-ms-flex-align:center;align-items:center}.bottom-md{-webkit-box-align:end;-ms-flex-align:end;align-items:flex-end}.around-md{-ms-flex-pack:distribute;justify-content:space-around}.between-md{-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between}.first-md{-webkit-box-ordinal-group:0;-ms-flex-order:-1;order:-1}.last-md{-webkit-box-ordinal-group:2;-ms-flex-order:1;order:1}}@media only screen and (min-width:75em){.container{width:76rem}.col-lg,.col-lg-1,.col-lg-10,.col-lg-11,.col-lg-12,.col-lg-2,.col-lg-3,.col-lg-4,.col-lg-5,.col-lg-6,.col-lg-7,.col-lg-8,.col-lg-9,.col-lg-offset-0,.col-lg-offset-1,.col-lg-offset-10,.col-lg-offset-11,.col-lg-offset-12,.col-lg-offset-2,.col-lg-offset-3,.col-lg-offset-4,.col-lg-offset-5,.col-lg-offset-6,.col-lg-offset-7,.col-lg-offset-8,.col-lg-offset-9{box-sizing:border-box;-webkit-box-flex:0;-ms-flex:0 0 auto;flex:none;padding-right:.5rem;padding-left:.5rem}.col-lg{-webkit-box-flex:1;-ms-flex-positive:1;flex-grow:1;-ms-flex-preferred-size:0;flex-basis:0;max-width:100%}.col-lg-1{-ms-flex-preferred-size:8.33333333%;flex-basis:8.33333333%;max-width:8.33333333%}.col-lg-2{-ms-flex-preferred-size:16.66666667%;flex-basis:16.66666667%;max-width:16.66666667%}.col-lg-3{-ms-flex-preferred-size:25%;flex-basis:25%;max-width:25%}.col-lg-4{-ms-flex-preferred-size:33.33333333%;flex-basis:33.33333333%;max-width:33.33333333%}.col-lg-5{-ms-flex-preferred-size:41.66666667%;flex-basis:41.66666667%;max-width:41.66666667%}.col-lg-6{-ms-flex-preferred-size:50%;flex-basis:50%;max-width:50%}.col-lg-7{-ms-flex-preferred-size:58.33333333%;flex-basis:58.33333333%;max-width:58.33333333%}.col-lg-8{-ms-flex-preferred-size:66.66666667%;flex-basis:66.66666667%;max-width:66.66666667%}.col-lg-9{-ms-flex-preferred-size:75%;flex-basis:75%;max-width:75%}.col-lg-10{-ms-flex-preferred-size:83.33333333%;flex-basis:83.33333333%;max-width:83.33333333%}.col-lg-11{-ms-flex-preferred-size:91.66666667%;flex-basis:91.66666667%;max-width:91.66666667%}.col-lg-12{-ms-flex-preferred-size:100%;flex-basis:100%;max-width:100%}.col-lg-offset-0{margin-left:0}.col-lg-offset-1{margin-left:8.33333333%}.col-lg-offset-2{margin-left:16.66666667%}.col-lg-offset-3{margin-left:25%}.col-lg-offset-4{margin-left:33.33333333%}.col-lg-offset-5{margin-left:41.66666667%}.col-lg-offset-6{margin-left:50%}.col-lg-offset-7{margin-left:58.33333333%}.col-lg-offset-8{margin-left:66.66666667%}.col-lg-offset-9{margin-left:75%}.col-lg-offset-10{margin-left:83.33333333%}.col-lg-offset-11{margin-left:91.66666667%}.start-lg{-webkit-box-pack:start;-ms-flex-pack:start;justify-content:flex-start;text-align:start}.center-lg{-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;text-align:center}.end-lg{-webkit-box-pack:end;-ms-flex-pack:end;justify-content:flex-end;text-align:end}.top-lg{-webkit-box-align:start;-ms-flex-align:start;align-items:flex-start}.middle-lg{-webkit-box-align:center;-ms-flex-align:center;align-items:center}.bottom-lg{-webkit-box-align:end;-ms-flex-align:end;align-items:flex-end}.around-lg{-ms-flex-pack:distribute;justify-content:space-around}.between-lg{-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between}.first-lg{-webkit-box-ordinal-group:0;-ms-flex-order:-1;order:-1}.last-lg{-webkit-box-ordinal-group:2;-ms-flex-order:1;order:1}}</style> - - - - - <link href="/index.xml" rel="alternate" type="application/rss+xml" - title="blog | garhve's hub"> - - <link rel="preconnect" href="https://fonts.gstatic.com"> - <link href="https://fonts.googleapis.com/css?family=Bree+Serif|Bungee+Shade" rel="stylesheet"> - - - -</head> - - -<body> - <article class="post English" id="article"> - <div class="row"> - <div class="col-xs-12"> - <div class="site-header"> - -<header> - <div class="header-title"> - <a href="/" - >Garhve</a - > - </div> - <div class="header-subtitle"></div> -</header> -<div class="row end-md center-xs header-items"> -</div> -<div class="row end-xs"> - - <div class="lang-switch col-xs-3 col-xs-offset-9"> - <a href="/cn/">Chinese</a> - </div> - -</div> -<div class="header-line"></div> - - </div> - <header class="post-header"> - <h1 class="post-title">Mess with bash(1)</h1> - - <div class="row post-desc"> - <div class="col-xs-6"> - - <time class="post-date" datetime="2022-08-25 13:40:56 CST"> - 25 Aug 2022 - </time> - - </div> - <div class="col-xs-6"> - - <div class="post-author"> - <a target="_blank" href="https://garhve.com">@garhve</a> - </div> - - </div> - </div> - - </header> - - <div class="post-content markdown-body"> - - <h3 id="crontab">Crontab</h3> -<p><code>crontab</code> is a useful tool, I really regret that I don’t familar it earlier.</p> -<p>It’s usage really simple, and these two are my frequent using:</p> -<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>crontab -e <span style="font-style:italic">#edit crontab file that reside in /var/spool/cron</span> -</span></span><span style="display:flex;"><span>crontab -l <span style="font-style:italic">#list current crontab job</span> -</span></span></code></pre></div><p>It basic syntax as follow, also really simple -<img src="https://assets.garhve.com/pictures/screenshots/2022/08/1857817000.jpg" alt="crontab-layout.jpg"></p> -<p>example of usage:</p> -<ol> -<li>delete file <em>foo</em> every minute -<code>* * * * * rm foo</code></li> -<li>delete file <em>foo</em> every 15 minutes -<code>15 * * * * rm foo</code></li> -<li>delete file <em>foo</em> every beginning of hour -<code>0 * * * * rm foo</code></li> -<li>delete file <em>foo</em> every minute after 3 hours -<code>* 3 * * * rm foo</code></li> -<li>delete file <em>foo</em> every day at 18:30 -<code>30 18 * * * rm foo</code></li> -<li>delete file <em>foo</em> every beginning of month -<code>0 0 0 * * rm foo</code></li> -<li>delete file <em>foo</em> on beginning of 1st,10th of month -<code>0 0 1,10 * * rm foo</code></li> -</ol> -<p>The usage really simple, I now use it to renew my SSL certification and daily update bt-tracker.</p> -<hr> -<h3 id="tr">tr</h3> -<p><code>tr</code> is really useful when encountered situation that needs struggle with string. -Three frequency ways of using <code>tr</code></p> -<ol> -<li> -<p><strong>shrink</strong> multiple characters into single one</p> -<p><code>tr -s '[string]'</code> -e.g. <code>echo "ssssssspaaaaace" | tr -s 'sa'</code> would convert “ssssssspace” to “space”</p> -</li> -<li> -<p><strong>delete</strong> specific character. I usually use it to delete white space or delimiter</p> -<p><code>tr -d '[string]'</code> -e.g. <code>echo "blog.garhve.com" | tr -d '.o'</code> would convert url to “blggarhvecm”</p> -</li> -<li> -<p><strong>convert</strong> specific character to another one.</p> -<p><code>tr '[string1]' '[string2]'</code> -e.g. <code>echo "woopwon | tr "wo" "fe"</code> would result “feepfen”</p> -</li> -</ol> -<hr> -<h3 id="cut">cut</h3> -<p>I use <code>cut</code> mostly to get word from a string, especially get relative path from absolute path. Because I always want to loop to get same sub-directories file from different main directory, <code>cut</code> helps a lot.</p> -<p>for now, I only use it one way</p> -<p><code>echo string | cut -d '[character]' -f position</code> -e.g. <code>echo path/to/most/inner/file | cut -d '/' -f1</code> this will give me word before first ‘/’, which is ‘path’</p> -<p>Often, <code>rev</code> will co-work with <code>cut</code> to get last one word</p> -<p>e.g. <code>echo blog.garhve.com | rev | cut -d '.' -f 1 | rev</code> this will give word after last ‘/’, which is com.</p> -<blockquote> -<p><em>a worth noting here is that the <code>rev</code> command needs to appear twice because it usage is not so intuitive, it reverse whole string</em></p> -<p><code>echo "hello world" | rev</code> will get ‘dlrow olleh`</p> -<p><code>echo "hello world" | cut -d ' ' -f1 | rev</code> will give result of ‘dlrow’</p> -<p><code>echo "hello world" | rev | cut -d ' ' -f1</code> will give same result, as ‘dlrow’</p> -<p><code>echo "hello world" | rev | cut -d ' ' -f1 | rev</code> will give expected result, as ‘world’</p> -</blockquote> -<h3 id="daily-update-bt-tracker">Daily update bt tracker</h3> -<p>I already learn shell script for a while.. so I wrote a simple script to test whether I really got used to it, but result is obviously, I need more and more practice to memorize commands.</p> -<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="">#! /bin/sh -</span></span></span><span style="display:flex;"><span><span style=""></span><span style="font-style:italic">#bt-tracker.txt</span> -</span></span><span style="display:flex;"><span>site=https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_all.txt -</span></span><span style="display:flex;"><span> -</span></span><span style="display:flex;"><span>file=/path_to_aria_directory/aria2.conf -</span></span><span style="display:flex;"><span> -</span></span><span style="display:flex;"><span>Addr=user@addr -</span></span><span style="display:flex;"><span> -</span></span><span style="display:flex;"><span><span style="font-style:italic"># Get bt-tracker and format it to fulfill aria needs, then store in variable</span> -</span></span><span style="display:flex;"><span>bt=<span style="font-weight:bold">$(</span>curl $site | tr -s <span style="font-style:italic">'[:space:]'</span> | tr <span style="font-style:italic">'[:space:]'</span> <span style="font-style:italic">','</span><span style="font-weight:bold">)</span> -</span></span><span style="display:flex;"><span> -</span></span><span style="display:flex;"><span><span style="font-style:italic"># sshpass is a software, that can allow me pass ssh password as argument</span> -</span></span><span style="display:flex;"><span><span style="font-style:italic"># so that I don't need to wait prompt</span> -</span></span><span style="display:flex;"><span><span style="font-style:italic"># 410 is the line of bt tracker resides, I now no other way to replace it.</span> -</span></span><span style="display:flex;"><span><span style="font-weight:bold">$(</span>sshpass -p <span style="font-style:italic">'password'</span> ssh -T $Addr <span style="font-style:italic">"sed -i '410d' </span>$file<span style="font-style:italic"> | echo </span>$bt<span style="font-style:italic"> >> </span>$file<span style="font-style:italic">"</span><span style="font-weight:bold">)</span> -</span></span></code></pre></div><blockquote> -<p>Usage of <a href="https://blog.garhve.com/index.php/archives/23/#tr">tr</a> and <a href="https://blog.garhve.com/index.php/archives/23/#cut">cut</a>, expansion of ‘command tips’ is needed</p> -</blockquote> -<h3 id="ways-to-find-files-or-specific-string-in-files">Ways to find files or specific string in files</h3> -<p>In order to look up C definitions, I need to know where linux stores header files or which files store definitions I need. So that here comes up some methods to fulfill this need:</p> -<ol> -<li><code>find 'path' -name 'file_name'</code></li> -</ol> -<blockquote> -<p>e.g. <code>find / -name stdio.h</code> will return multiple location that stdio.h resides. this could expand to look for others</p> -<p><img src="https://assets.garhve.com/pictures/screenshots/2022/09/find_name.png" alt="image.png"></p> -<p>more info could see <code>man find</code></p> -</blockquote> -<hr> -<ol start="2"> -<li><code>grep -rnw 'path' -e 'pattern'</code></li> -</ol> -<blockquote> -<p>e.g. `grep –include=*.{h,c} -rnw / -e “from_kuid” will return string and filename that contains string.</p> -<p><img src="https://assets.garhve.com/pictures/screenshots/2022/09/grep_string.png" alt="image.png"></p> -<ul> -<li><code>-r</code> or <code>-R</code> is recursive,</li> -<li><code>-n</code> is line number, and</li> -<li><code>-w</code> stands for match the whole word.</li> -<li><code>-l</code> (lower-case L) can be added to just give the file name of matching files.</li> -<li><code>-e</code> is the pattern used during the search</li> -</ul> -<p>Along with these, <code>--exclude</code>, <code>--include</code>, <code>--exclude-dir</code> flags could be used for efficient searching:</p> -<ul> -<li>This will only search through those files which have .c or .h extensions:</li> -</ul> -<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>grep --include=<span style="font-weight:bold;font-style:italic">\*</span>.{c,h} -rnw <span style="font-style:italic">'/path/to/somewhere/'</span> -e <span style="font-style:italic">"pattern"</span> -</span></span></code></pre></div><ul> -<li>This will exclude searching all the files ending with .o extension:</li> -</ul> -<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>grep --exclude=<span style="font-weight:bold;font-style:italic">\*</span>.o -rnw <span style="font-style:italic">'/path/to/somewhere/'</span> -e <span style="font-style:italic">"pattern"</span> -</span></span></code></pre></div><ul> -<li>For directories it’s possible to exclude one or more directories using the <code>--exclude-dir</code> parameter. For example, this will exclude the dirs dir1/, dir2/ and all of them matching *.dst/:</li> -</ul> -<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>grep --exclude-dir={dir1,dir2,*.dst} -rnw <span style="font-style:italic">'/path/to/somewhere/'</span> -e <span style="font-style:italic">"pattern"</span> -</span></span></code></pre></div><p>more info could see <a href="https://ss64.com/bash/grep.html"><code>man grep</code></a>.</p> -</blockquote> - - </div> - - <div class="row"> - <div class="col-xs-12"> - - </div> - </div> - - - <div style="height: 50px;"></div> - - - <div class="site-footer"> - - - -</div> - - </div> - </div> - </article> - - - -<script> - - - - - -</script> - - - -</body> - -</html> |