urlencoding与一个纯BASH内置

opposite of https://www.commandlinefu.com/commands/view/10014/urldecoding-with-one-pure-bash-builtin ;-)
.

0

linux命令:function URLEncode { local dataLength="${#1}"; local index; for ((index = 0;index < dataLength;index++)); do local char="${1:index:1}"; case $char in [a-zA-Z0-9.~_-]) printf "$char"; ;; *) printf "%%%02X" "'$char"; ;; esac; done; } } done; esac; ;; "'$char"; "%%%02X" printf *) ;; "$char"; printf [a-zA-Z0-9.~_-]) in $char case char="${1:index:1}"; local do dataLength;index++)); < 0;index = ((index for index; local dataLength="${#1}"; local { URLEncode function function URLEncode { local dataLength="${#1}"; local index; for ((index = 0;index < dataLength;index++)); do local char="${1:index:1}"; case $char in [a-zA-Z0-9.~_-]) printf "$char"; ;; *) printf "%%%02X" "'$char"; ;; esac; done; }rootopen.com
linux命令:function URLEncode { local dataLength="${#1}"; local index; for ((index = 0;index < dataLength;index++)); do local char="${1:index:1}"; case $char in [a-zA-Z0-9.~_-]) printf "$char"; ;; *) printf "%%%02X" "'$char"; ;; esac; done; } } done; esac; ;; "'$char"; "%%%02X" printf *) ;; "$char"; printf [a-zA-Z0-9.~_-]) in $char case char="${1:index:1}"; local do dataLength;index++)); < 0;index = ((index for index; local dataLength="${#1}"; local { URLEncode function function URLEncode { local dataLength="${#1}"; local index; for ((index = 0;index < dataLength;index++)); do local char="${1:index:1}"; case $char in [a-zA-Z0-9.~_-]) printf "$char"; ;; *) printf "%%%02X" "'$char"; ;; esac; done; }rootopen.com
mi莎 2018-09-11 09:55:30
输出
URLEncode https://www.commandlinefu.com/commands/by/emphazer

https%3A%2F%2Fwww.commandlinefu.com%2Fcommands%2Fby%2Femphazer
linux命令:function 详解

评论

相关推荐

linux命令:function hibp() { sha1=$(echo -n "$1"|sha1sum|awk '{print toupper($0)}'|tr -d '\n'); curl -s -H $'Referer: https://haveibeenpwned.com/' https://api.pwnedpasswords.com/range/$(echo -n $sha1|cut -c1-5)|grep -i $(echo -n $sha1|cut -c6-40); } } -c6-40); $sha1|cut -n $(echo -i -c1-5)|grep $sha1|cut -n https://api.pwnedpasswords.com/range/$(echo https://haveibeenpwned.com/' $'Referer: -H -s curl '\n'); -d toupper($0)}'|tr '{print "$1"|sha1sum|awk -n sha1=$(echo { hibp() function function hibp() { sha1=$(echo -n "$1"|sha1sum|awk '{print toupper($0)}'|tr -d '\n'); curl -s -H $'Referer: https://haveibeenpwned.com/' https://api.pwnedpasswords.com/range/$(echo -n $sha1|cut -c1-5)|grep -i $(echo -n $sha1|cut -c6-40); }rootopen.com
linux命令:function hibp() { sha1=$(echo -n "$1"|sha1sum|awk '{print toupper($0)}'|tr -d '\n'); curl -s -H $'Referer: https://haveibeenpwned.com/' https://api.pwnedpasswords.com/range/$(echo -n $sha1|cut -c1-5)|grep -i $(echo -n $sha1|cut -c6-40); } } -c6-40); $sha1|cut -n $(echo -i -c1-5)|grep $sha1|cut -n https://api.pwnedpasswords.com/range/$(echo https://haveibeenpwned.com/' $'Referer: -H -s curl '\n'); -d toupper($0)}'|tr '{print "$1"|sha1sum|awk -n sha1=$(echo { hibp() function function hibp() { sha1=$(echo -n "$1"|sha1sum|awk '{print toupper($0)}'|tr -d '\n'); curl -s -H $'Referer: https://haveibeenpwned.com/' https://api.pwnedpasswords.com/range/$(echo -n $sha1|cut -c1-5)|grep -i $(echo -n $sha1|cut -c6-40); }rootopen.com
.

linux命令:function hibp() { sha1=$(echo -n "$1"|sha1sum|awk '{print toupper($0)}'|tr -d '\n'); curl -s -H $'Referer: https://haveibeenpwned.com/' https://api.pwnedpasswords.com/range/$(echo -n $sha1|cut -c1-5)|grep -i $(echo -n $sha1|cut -c6-40); } } -c6-40); $sha1|cut -n $(echo -i -c1-5)|grep $sha1|cut -n https://api.pwnedpasswords.com/range/$(echo https://haveibeenpwned.com/' $'Referer: -H -s curl '\n'); -d toupper($0)}'|tr '{print "$1"|sha1sum|awk -n sha1=$(echo { hibp() function function hibp() { sha1=$(echo -n "$1"|sha1sum|awk '{print toupper($0)}'|tr -d '\n'); curl -s -H $'Referer: https://haveibeenpwned.com/' https://api.pwnedpasswords.com/range/$(echo -n $sha1|cut -c1-5)|grep -i $(echo -n $sha1|cut -c6-40); }rootopen.com
linux命令:function hibp() { sha1=$(echo -n "$1"|sha1sum|awk '{print toupper($0)}'|tr -d '\n'); curl -s -H $'Referer: https://haveibeenpwned.com/' https://api.pwnedpasswords.com/range/$(echo -n $sha1|cut -c1-5)|grep -i $(echo -n $sha1|cut -c6-40); } } -c6-40); $sha1|cut -n $(echo -i -c1-5)|grep $sha1|cut -n https://api.pwnedpasswords.com/range/$(echo https://haveibeenpwned.com/' $'Referer: -H -s curl '\n'); -d toupper($0)}'|tr '{print "$1"|sha1sum|awk -n sha1=$(echo { hibp() function function hibp() { sha1=$(echo -n "$1"|sha1sum|awk '{print toupper($0)}'|tr -d '\n'); curl -s -H $'Referer: https://haveibeenpwned.com/' https://api.pwnedpasswords.com/range/$(echo -n $sha1|cut -c1-5)|grep -i $(echo -n $sha1|cut -c6-40); }rootopen.com
.

此功能可以轻松计算X / Y百分比。“wpoxiy”这个名字的缩写是“X是Y的百分比”

linux命令:function wpoxiy () { # What percentage of X is Y? Where percent/100 = X/Y => percent=100*X/Y # Example: wpoxiy 10 5 # 50.00% # Example: wpoxiy 30 10 # 33.33% echo $(bc <<< "scale=2; y=${1}; x=${2}; percent=x*100/y; percent")"%"; } } percent")"%"; percent=x*100/y; x=${2}; y=${1}; "scale=2; <<< $(bc echo 33.33% # 10 30 wpoxiy Example: # 50.00% # 5 10 wpoxiy Example: # percent=100*X/Y => X/Y = percent/100 Where Y? is X of percentage What # { () wpoxiy function function wpoxiy () { # What percentage of X is Y? Where percent/100 = X/Y => percent=100*X/Y # Example: wpoxiy 10 5 # 50.00% # Example: wpoxiy 30 10 # 33.33% echo $(bc <<< "scale=2; y=${1}; x=${2}; percent=x*100/y; percent")"%"; }rootopen.com
linux命令:function wpoxiy () { # What percentage of X is Y? Where percent/100 = X/Y => percent=100*X/Y # Example: wpoxiy 10 5 # 50.00% # Example: wpoxiy 30 10 # 33.33% echo $(bc <<< "scale=2; y=${1}; x=${2}; percent=x*100/y; percent")"%"; } } percent")"%"; percent=x*100/y; x=${2}; y=${1}; "scale=2; <<< $(bc echo 33.33% # 10 30 wpoxiy Example: # 50.00% # 5 10 wpoxiy Example: # percent=100*X/Y => X/Y = percent/100 Where Y? is X of percentage What # { () wpoxiy function function wpoxiy () { # What percentage of X is Y? Where percent/100 = X/Y => percent=100*X/Y # Example: wpoxiy 10 5 # 50.00% # Example: wpoxiy 30 10 # 33.33% echo $(bc <<< "scale=2; y=${1}; x=${2}; percent=x*100/y; percent")"%"; }rootopen.com
.

有时你使用SSH(主机更改IP,IP现在属于另一台机器)发生冲突,您需要编辑该文件并从known_hosts中删除有问题的行。这很容易。

linux命令:function sshdel { perl -i -n -e "print unless (\$. == $1)" ~/.ssh/known_hosts; } } ~/.ssh/known_hosts; $1)" == (\$. unless "print -e -n -i perl { sshdel function function sshdel { perl -i -n -e "print unless (\$. == $1)" ~/.ssh/known_hosts; }rootopen.com
linux命令:function sshdel { perl -i -n -e "print unless (\$. == $1)" ~/.ssh/known_hosts; } } ~/.ssh/known_hosts; $1)" == (\$. unless "print -e -n -i perl { sshdel function function sshdel { perl -i -n -e "print unless (\$. == $1)" ~/.ssh/known_hosts; }rootopen.com
.

只需将参数传递给脚本即可将手册页转换为PDF:man2pdf drutil

linux命令:function man2pdf(){ man -t ${1:?Specify man as arg} | open -f -a preview; } } preview; -a -f open | arg} as man ${1:?Specify -t man man2pdf(){ function function man2pdf(){ man -t ${1:?Specify man as arg} | open -f -a preview; }rootopen.com
linux命令:function man2pdf(){ man -t ${1:?Specify man as arg} | open -f -a preview; } } preview; -a -f open | arg} as man ${1:?Specify -t man man2pdf(){ function function man2pdf(){ man -t ${1:?Specify man as arg} | open -f -a preview; }rootopen.com
.

将函数添加到.bashrc以使其工作。示例:首先进入iso文件目录并键入:---------------------------- -------------------------------------------------- ---------------------- user @ box:〜$ miso file.iso ------------------ -------------------------------------------------- --------------------------------它会把你放到临时挂载点目录(ISO_CD)并显示文件无论您的目录是什么,都可以卸载iso文件---------------------------------------- -------------------------------------------------- ---------- user @ box:〜/ ISO_CD $ uiso ------------------------------- -------------------------------------------------- -------------------它将卸载iso文件并删除您家中的临时目录

linux命令:function miso () { mkdir ~/ISO_CD && sudo mount -o loop "$@" ~/ISO_CD && cd ~/ISO_CD && ls; } function uiso () { cd ~ && sudo umount ~/ISO_CD && rm -r ~/ISO_CD; } } ~/ISO_CD; -r rm && ~/ISO_CD umount sudo && ~ cd { () uiso function } ls; && ~/ISO_CD cd && ~/ISO_CD "$@" loop -o mount sudo && ~/ISO_CD mkdir { () miso function function miso () { mkdir ~/ISO_CD && sudo mount -o loop "$@" ~/ISO_CD && cd ~/ISO_CD && ls; } function uiso () { cd ~ && sudo umount ~/ISO_CD && rm -r ~/ISO_CD; }rootopen.com
linux命令:function miso () { mkdir ~/ISO_CD && sudo mount -o loop "$@" ~/ISO_CD && cd ~/ISO_CD && ls; } function uiso () { cd ~ && sudo umount ~/ISO_CD && rm -r ~/ISO_CD; } } ~/ISO_CD; -r rm && ~/ISO_CD umount sudo && ~ cd { () uiso function } ls; && ~/ISO_CD cd && ~/ISO_CD "$@" loop -o mount sudo && ~/ISO_CD mkdir { () miso function function miso () { mkdir ~/ISO_CD && sudo mount -o loop "$@" ~/ISO_CD && cd ~/ISO_CD && ls; } function uiso () { cd ~ && sudo umount ~/ISO_CD && rm -r ~/ISO_CD; }rootopen.com
.

在输入cd目录[enter] ls [enter]很多次之后,我想我会尝试将它变成一个函数。我很惊讶,我能够很顺利地将它集成到我的命令行工作中。只要使用cdls,就像你会cd。进入目录后,它会自动列出目录内容。要使命令始终可用,请将其添加到.bashrc文件中。不是很有纪念意义,但仍然非常方便。

linux命令:function cdls { cd $1; ls; } } ls; $1; cd { cdls function function cdls { cd $1; ls; }rootopen.com
linux命令:function cdls { cd $1; ls; } } ls; $1; cd { cdls function function cdls { cd $1; ls; }rootopen.com
.

运行“cpan Module :: Name”将从CPAN安装该模块。这是使用类似命令从apt-get使用Debian存档安装打包的Perl模块的简单方法。

linux命令:function dpan () { PKG=`perl -e '$_=lc($ARGV[0]); s/::/-/g; print "lib$_-perl\n"' $1`; apt-get install $PKG; } } $PKG; install apt-get $1`; "lib$_-perl\n"' print s/::/-/g; '$_=lc($ARGV[0]); -e PKG=`perl { () dpan function function dpan () { PKG=`perl -e '$_=lc($ARGV[0]); s/::/-/g; print "lib$_-perl\n"' $1`; apt-get install $PKG; }rootopen.com
linux命令:function dpan () { PKG=`perl -e '$_=lc($ARGV[0]); s/::/-/g; print "lib$_-perl\n"' $1`; apt-get install $PKG; } } $PKG; install apt-get $1`; "lib$_-perl\n"' print s/::/-/g; '$_=lc($ARGV[0]); -e PKG=`perl { () dpan function function dpan () { PKG=`perl -e '$_=lc($ARGV[0]); s/::/-/g; print "lib$_-perl\n"' $1`; apt-get install $PKG; }rootopen.com
.

在其他地方的某个时间后回到项目目录?需要知道最近修改过的文件是什么?这个小函数“t”是我最常用的命令之一。我也有一个tcsh别名:alias t'ls -ltch \!* |头-20'

linux命令:function t { ls -ltch $* | head -20 ; } } ; -20 head | $* -ltch ls { t function function t { ls -ltch $* | head -20 ; }rootopen.com
linux命令:function t { ls -ltch $* | head -20 ; } } ; -20 head | $* -ltch ls { t function function t { ls -ltch $* | head -20 ; }rootopen.com
.

这个小命令(函数)将CSV标题字段(它们是以逗号分隔的字段名称)显示为有序列表,清楚地显示字段及其顺序。

linux命令:function headers { head -1 $* | tr ',' '\12' | pr -t -n ; } } ; -n -t pr | '\12' ',' tr | $* -1 head { headers function function headers { head -1 $* | tr ',' '\12' | pr -t -n ; }rootopen.com
linux命令:function headers { head -1 $* | tr ',' '\12' | pr -t -n ; } } ; -n -t pr | '\12' ',' tr | $* -1 head { headers function function headers { head -1 $* | tr ',' '\12' | pr -t -n ; }rootopen.com
.

许多Mac OS X程序(尤其是Microsoft:Office中的程序)都会创建带有由CR(回车)终止的行的ASCII文件。大多数Unix程序都希望线由NL(换行符)分开。这个小命令使得转换它们变得微不足道。

linux命令:function crtonl { perl -i -ape 's/\r\n?/\n/g;' $* ; } } ; $* 's/\r\n?/\n/g;' -ape -i perl { crtonl function function crtonl { perl -i -ape 's/\r\n?/\n/g;' $* ; }rootopen.com
linux命令:function crtonl { perl -i -ape 's/\r\n?/\n/g;' $* ; } } ; $* 's/\r\n?/\n/g;' -ape -i perl { crtonl function function crtonl { perl -i -ape 's/\r\n?/\n/g;' $* ; }rootopen.com
.

您无法忍受节目x,y和z。通过将此功能添加到您的配置中,删除它们存在的所有痕迹。它会删除cruft,设置等等。这个函数甚至不会对你试图删除不存在的程序一无所知:它只是为了循环到你命中列表中的下一个程序。

linux命令:function nuke() { if [ $(whoami) != "root" ] ; then for x in $@; do sudo apt-get autoremove --purge $x; done; else for x in $@; do apt-get autoremove --purge $x; done; fi } } fi done; $x; --purge autoremove apt-get do $@; in x for else done; $x; --purge autoremove apt-get sudo do $@; in x for then ; ] "root" != $(whoami) [ if { nuke() function function nuke() { if [ $(whoami) != "root" ] ; then for x in $@; do sudo apt-get autoremove --purge $x; done; else for x in $@; do apt-get autoremove --purge $x; done; fi }rootopen.com
linux命令:function nuke() { if [ $(whoami) != "root" ] ; then for x in $@; do sudo apt-get autoremove --purge $x; done; else for x in $@; do apt-get autoremove --purge $x; done; fi } } fi done; $x; --purge autoremove apt-get do $@; in x for else done; $x; --purge autoremove apt-get sudo do $@; in x for then ; ] "root" != $(whoami) [ if { nuke() function function nuke() { if [ $(whoami) != "root" ] ; then for x in $@; do sudo apt-get autoremove --purge $x; done; else for x in $@; do apt-get autoremove --purge $x; done; fi }rootopen.com
.

该功能在后台运行程序,并将所有输出记录到自动创建的日志文件中。这样,你仍然可以得到输出,而不会堵塞你的终端。提示:抛出fork()和这个:for prog in firefox kate konqueror;别名$ prog =“fork $ prog”; doneinto你的bashrc,这样他们会自动跑出来的。

linux命令:function fork () { tf=$(tempfile -d /tmp -p $1.);echo -n "$tf "; $@ &>$tf& } } &>$tf& $@ "; "$tf -n $1.);echo -p /tmp -d tf=$(tempfile { () fork function function fork () { tf=$(tempfile -d /tmp -p $1.);echo -n "$tf "; $@ &>$tf& }rootopen.com
linux命令:function fork () { tf=$(tempfile -d /tmp -p $1.);echo -n "$tf "; $@ &>$tf& } } &>$tf& $@ "; "$tf -n $1.);echo -p /tmp -d tf=$(tempfile { () fork function function fork () { tf=$(tempfile -d /tmp -p $1.);echo -n "$tf "; $@ &>$tf& }rootopen.com
.

允许您在不提交的情况下保存进度。要恢复到撤消点,svn将恢复,然后使用patch.svn revert -R应用撤消点。 && patch -p0 <.undo / 2009-03-27_08:08:11rev57Similar:http://www.commandlinefu.com/commands/view/373/archive-all-files-containing-local-changes-svn

linux命令:function svnundopoint() { if [ -d .undo ]; then r=`svn info | grep Revision | cut -f 2 -d ' '` && t=`date +%F_%T` && f=${t}rev${r} && svn diff>.undo/$f && svn stat>.undo/stat_$f; else echo Missing .undo directory; fi } } fi directory; .undo Missing echo else stat>.undo/stat_$f; svn && diff>.undo/$f svn && f=${t}rev${r} && +%F_%T` t=`date && '` ' -d 2 -f cut | Revision grep | info r=`svn then ]; .undo -d [ if { svnundopoint() function function svnundopoint() { if [ -d .undo ]; then r=`svn info | grep Revision | cut -f 2 -d ' '` && t=`date +%F_%T` && f=${t}rev${r} && svn diff>.undo/$f && svn stat>.undo/stat_$f; else echo Missing .undo directory; fi }rootopen.com
linux命令:function svnundopoint() { if [ -d .undo ]; then r=`svn info | grep Revision | cut -f 2 -d ' '` && t=`date +%F_%T` && f=${t}rev${r} && svn diff>.undo/$f && svn stat>.undo/stat_$f; else echo Missing .undo directory; fi } } fi directory; .undo Missing echo else stat>.undo/stat_$f; svn && diff>.undo/$f svn && f=${t}rev${r} && +%F_%T` t=`date && '` ' -d 2 -f cut | Revision grep | info r=`svn then ]; .undo -d [ if { svnundopoint() function function svnundopoint() { if [ -d .undo ]; then r=`svn info | grep Revision | cut -f 2 -d ' '` && t=`date +%F_%T` && f=${t}rev${r} && svn diff>.undo/$f && svn stat>.undo/stat_$f; else echo Missing .undo directory; fi }rootopen.com
.

用法:在Shell中声明这个函数,然后像这样使用它:> jumpTo foo脚本将搜索当前xmms2播放列表(艺术家或歌曲名)中的'foo'模式,并播放它的第一次出现!

linux命令:function jumpTo { xmms2 jump `xmms2 list | grep -i '$1' | head -n 1 | tail -n 1 | sed -re 's@.+\[(.+)/.+\] (.+)@\1@'`; } } (.+)@\1@'`; 's@.+\[(.+)/.+\] -re sed | 1 -n tail | 1 -n head | '$1' -i grep | list `xmms2 jump xmms2 { jumpTo function function jumpTo { xmms2 jump `xmms2 list | grep -i '$1' | head -n 1 | tail -n 1 | sed -re 's@.+\[(.+)/.+\] (.+)@\1@'`; }rootopen.com
linux命令:function jumpTo { xmms2 jump `xmms2 list | grep -i '$1' | head -n 1 | tail -n 1 | sed -re 's@.+\[(.+)/.+\] (.+)@\1@'`; } } (.+)@\1@'`; 's@.+\[(.+)/.+\] -re sed | 1 -n tail | 1 -n head | '$1' -i grep | list `xmms2 jump xmms2 { jumpTo function function jumpTo { xmms2 jump `xmms2 list | grep -i '$1' | head -n 1 | tail -n 1 | sed -re 's@.+\[(.+)/.+\] (.+)@\1@'`; }rootopen.com
.

减少在vim中打开文件所需的击键次数。首先,你只需要输入“v”,这个数字少于字符数量的一半(!),其次,你只需要输入你想打开的文件的子字符串。例如,如果你想打开文件homework.txt,然后输入“v hom”打开它。好的提示是使用最小的唯一子字符串,否则你将在不同的缓冲区中打开多个文件(这有时是可取的)。使用Ctrl- ^在缓冲区之间切换。

linux命令:function v { if [ -z $1 ]; then vim; else vim *$1*; fi } } fi *$1*; vim else vim; then ]; $1 -z [ if { v function function v { if [ -z $1 ]; then vim; else vim *$1*; fi }rootopen.com
linux命令:function v { if [ -z $1 ]; then vim; else vim *$1*; fi } } fi *$1*; vim else vim; then ]; $1 -z [ if { v function function v { if [ -z $1 ]; then vim; else vim *$1*; fi }rootopen.com
.

函数echox {echo`tput cup $(($(tput lines)))$((($(tput cols) - $(echo“$ {#1}”))/ 2))``$ 1“`tput cup $(输出线)$(($(输入列)-1))`; (echo $ tput cup $(($(tput lines)/ 2))$((($(tput cols) - $(echo“$ {#1}”)} echox在底线中心屏幕上打印给定参数。 ))/ 2))`“$ 1”`tput cup $(tput lines)$(($(tput cols)-1))`; }给出参数中心的exhoxy打印screenfunction echo {echo`tput cup $(($(tput lines)-2))$(($(tput cols) - $(echo $ {#1})))&& tput sc`“$ 1 “`tput cup $(($(tput lines)-2))0 && tput rc`; [1];做回声“日期”; doneechos在最后一行的第二行打印日期和时间(用作状态消息),您可以通过将它们放在.bashrc文件中来轻松使用这些函数,确保在您执行操作时获取.bashrc

linux命令:function echox { echo `tput cup $(($(tput lines))) $(( ($(tput cols) - $(echo "${#1}"))/2 ))`"$1"`tput cup $(tput lines) $(( $(tput cols)-1 ))`; } } ))`; cols)-1 $(tput $(( lines) $(tput cup ))`"$1"`tput "${#1}"))/2 $(echo - cols) ($(tput $(( lines))) $(($(tput cup `tput echo { echox function function echox { echo `tput cup $(($(tput lines))) $(( ($(tput cols) - $(echo "${#1}"))/2 ))`"$1"`tput cup $(tput lines) $(( $(tput cols)-1 ))`; }rootopen.com
linux命令:function echox { echo `tput cup $(($(tput lines))) $(( ($(tput cols) - $(echo "${#1}"))/2 ))`"$1"`tput cup $(tput lines) $(( $(tput cols)-1 ))`; } } ))`; cols)-1 $(tput $(( lines) $(tput cup ))`"$1"`tput "${#1}"))/2 $(echo - cols) ($(tput $(( lines))) $(($(tput cup `tput echo { echox function function echox { echo `tput cup $(($(tput lines))) $(( ($(tput cols) - $(echo "${#1}"))/2 ))`"$1"`tput cup $(tput lines) $(( $(tput cols)-1 ))`; }rootopen.com
.

ec将更改提交给etckeepermust使用bzr安装etckeeper以在bashrc内部使用此位置可用于从任何目录提交更改

linux命令:function ec() { ec_var="`pwd`" && cd /etc/ && sudo bzr commit -m "$@" && cd $ec_var; } } $ec_var; cd && "$@" -m commit bzr sudo && /etc/ cd && ec_var="`pwd`" { ec() function function ec() { ec_var="`pwd`" && cd /etc/ && sudo bzr commit -m "$@" && cd $ec_var; }rootopen.com
linux命令:function ec() { ec_var="`pwd`" && cd /etc/ && sudo bzr commit -m "$@" && cd $ec_var; } } $ec_var; cd && "$@" -m commit bzr sudo && /etc/ cd && ec_var="`pwd`" { ec() function function ec() { ec_var="`pwd`" && cd /etc/ && sudo bzr commit -m "$@" && cd $ec_var; }rootopen.com
.

这是为了bash shell。把这个函数放在你的.profile文件中,你就可以使用tab-completion来对任何在你的known_hosts文件中的主机进行sshing。这假定您的known_hosts文件位于〜/ .ssh / known_hosts。 “complete”命令应该在单独的行上,如下所示:function autoCompleteHostname(){local hosts =($(awk'{print $ 1}'〜/ .ssh / known_hosts | cut -d,-f1));本地cur = $ {COMP_WORDS [COMP_CWORD]}; COMPREPLY =($(compgen -W'$ {hosts [@]}' - $ cur))} complete -F autoCompleteHostname ssh

linux命令:function autoCompleteHostname() { local hosts; local cur; hosts=($(awk '{print $1}' ~/.ssh/known_hosts | cut -d, -f1)); cur=${COMP_WORDS[COMP_CWORD]}; COMPREPLY=($(compgen -W '${hosts[@]}' -- $cur )) } complete -F autoCompleteHostname ssh ssh autoCompleteHostname -F complete } )) $cur -- '${hosts[@]}' -W COMPREPLY=($(compgen cur=${COMP_WORDS[COMP_CWORD]}; -f1)); -d, cut | ~/.ssh/known_hosts $1}' '{print hosts=($(awk cur; local hosts; local { autoCompleteHostname() function function autoCompleteHostname() { local hosts; local cur; hosts=($(awk '{print $1}' ~/.ssh/known_hosts | cut -d, -f1)); cur=${COMP_WORDS[COMP_CWORD]}; COMPREPLY=($(compgen -W '${hosts[@]}' -- $cur )) } complete -F autoCompleteHostname sshrootopen.com
linux命令:function autoCompleteHostname() { local hosts; local cur; hosts=($(awk '{print $1}' ~/.ssh/known_hosts | cut -d, -f1)); cur=${COMP_WORDS[COMP_CWORD]}; COMPREPLY=($(compgen -W '${hosts[@]}' -- $cur )) } complete -F autoCompleteHostname ssh ssh autoCompleteHostname -F complete } )) $cur -- '${hosts[@]}' -W COMPREPLY=($(compgen cur=${COMP_WORDS[COMP_CWORD]}; -f1)); -d, cut | ~/.ssh/known_hosts $1}' '{print hosts=($(awk cur; local hosts; local { autoCompleteHostname() function function autoCompleteHostname() { local hosts; local cur; hosts=($(awk '{print $1}' ~/.ssh/known_hosts | cut -d, -f1)); cur=${COMP_WORDS[COMP_CWORD]}; COMPREPLY=($(compgen -W '${hosts[@]}' -- $cur )) } complete -F autoCompleteHostname sshrootopen.com
.

我发现我创建了一个目录,然后经常进入该目录。我在互联网上发现了这个小功能,并认为我会分享它。只需将它复制粘贴到你的〜/ .bash_profile然后是'source〜/ .bash_profile`。

linux命令:function mcd() { [ -n "$1" ] && mkdir -p "$@" && cd "$1"; } } "$1"; cd && "$@" -p mkdir && ] "$1" -n [ { mcd() function function mcd() { [ -n "$1" ] && mkdir -p "$@" && cd "$1"; }rootopen.com
linux命令:function mcd() { [ -n "$1" ] && mkdir -p "$@" && cd "$1"; } } "$1"; cd && "$@" -p mkdir && ] "$1" -n [ { mcd() function function mcd() { [ -n "$1" ] && mkdir -p "$@" && cd "$1"; }rootopen.com
.
共收录0条命令行
这里是记录和分享命令行的地方, 所有命令行都可以进行评论、提交替代方案.

推荐
    热门命令