goreliu / zshguide Goto Github PK
View Code? Open in Web Editor NEWZsh 开发指南
Home Page: https://zshguide.readthedocs.io
License: GNU General Public License v3.0
Zsh 开发指南
Home Page: https://zshguide.readthedocs.io
License: GNU General Public License v3.0
1.a=$(grep a test)
echo ${(t)a}
得到: scalar
但:echo
就什么输出都没有
2.test文件有一行是以$为开头的
echo
结果输出是没问题的
但当我把$换成单引号
echo ${"$(<test)"[(fr)\‘]}
结果就是什么输出也没有,明明文件里有这一行,但是却没有匹配成功
3.还有就是那个(r)变量修饰符,我花了老大的劲才试出来它原来是不支持正则的,支持的是通配符
回想一开始学python的时候,根本没有这么多事。。
我的思路是要么读入整体文件转为数组array=(${(f)"$(<test.txt)"})
,要么用while {read line}
逐行读取。
但遇到空行都会忽略。我猜测是(f)转换时就会跳过空行,而while方案也会有一样的问题(可能是read返回值问题交给while判断出错,或者read本身就是忽略空行的)。导致单纯通过zsh做逐行处理还原一个文件成了不可能的任务(不想用sed这些指令)。
为此我还试了read的各种参数,搞了整整一个下午,有种条条大路是死路的感觉。。
求教大佬有没有什么方法能在纯shell脚本中解决这类问题?
touch a.txt
file a.txt # 文件为空
print -l *(.^F) 这样才能选中这个空文件
in 14.md:127
str +="\n$str"
should be
str+="\n$str"
thanks!
异常处理语句
{
语句 1
} always {
语句 2
}
如果语句 1 执行出错,则执行语句 2。
{
true
} always{
echo yyy
}
{
false
} always{
echo yyy
}
结果都是会输出yyy
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.