Artwork

内容由HPR Volunteer and Hacker Public Radio提供。所有播客内容(包括剧集、图形和播客描述)均由 HPR Volunteer and Hacker Public Radio 或其播客平台合作伙伴直接上传和提供。如果您认为有人在未经您许可的情况下使用您的受版权保护的作品,您可以按照此处概述的流程进行操作https://zh.player.fm/legal
Player FM -播客应用
使用Player FM应用程序离线!

HPR3625: Shell Tips and Snippets - Collaborative Effort

 
分享
 

Manage episode 332706330 series 2795599
内容由HPR Volunteer and Hacker Public Radio提供。所有播客内容(包括剧集、图形和播客描述)均由 HPR Volunteer and Hacker Public Radio 或其播客平台合作伙伴直接上传和提供。如果您认为有人在未经您许可的情况下使用您的受版权保护的作品,您可以按照此处概述的流程进行操作https://zh.player.fm/legal

Carl talks about a method to move function definitions to the bottom of a script using sed:

#!/bin/sh source <(sed '1,/^exit/ d' $0) __say "hello" exit __say() { echo $1 } 

Guest Host #1 (scroll to the bottom to ruin the surprise) talks about the shift command using this example:

startdate="$1" # Pick up date shift days=0 # Loop through args and create events while [ $1 ] ; do # as many times as you add a timestamp [ $1 != "off" ] && khal new $(date -j -v+"$days"d -f %Y-%m-%d +%Y-%m-%d $startdate) $1 8H Work let days++ shift done 

Guest Host #2 provides tips and examples on how to use variables safely and politely provide default values. One example of assigning a default value is:

foo=${foo:-"blah"} 

Carl then closes out with the : (colon) shell builtin and provides a variation on the above default value:

: ${foo:="blah"} 
  continue reading

63集单集

Artwork
icon分享
 
Manage episode 332706330 series 2795599
内容由HPR Volunteer and Hacker Public Radio提供。所有播客内容(包括剧集、图形和播客描述)均由 HPR Volunteer and Hacker Public Radio 或其播客平台合作伙伴直接上传和提供。如果您认为有人在未经您许可的情况下使用您的受版权保护的作品,您可以按照此处概述的流程进行操作https://zh.player.fm/legal

Carl talks about a method to move function definitions to the bottom of a script using sed:

#!/bin/sh source <(sed '1,/^exit/ d' $0) __say "hello" exit __say() { echo $1 } 

Guest Host #1 (scroll to the bottom to ruin the surprise) talks about the shift command using this example:

startdate="$1" # Pick up date shift days=0 # Loop through args and create events while [ $1 ] ; do # as many times as you add a timestamp [ $1 != "off" ] && khal new $(date -j -v+"$days"d -f %Y-%m-%d +%Y-%m-%d $startdate) $1 8H Work let days++ shift done 

Guest Host #2 provides tips and examples on how to use variables safely and politely provide default values. One example of assigning a default value is:

foo=${foo:-"blah"} 

Carl then closes out with the : (colon) shell builtin and provides a variation on the above default value:

: ${foo:="blah"} 
  continue reading

63集单集

所有剧集

×
 
Loading …

欢迎使用Player FM

Player FM正在网上搜索高质量的播客,以便您现在享受。它是最好的播客应用程序,适用于安卓、iPhone和网络。注册以跨设备同步订阅。

 

快速参考指南