我创建了一个名为shell的脚本,blossom()
因为我女友的狗Blossom一直在地板上撒尿。
blossom() {
echo poops and pees on floor all the time
}
因为我是个很好奇的孩子,所以我想搜索此shell的存储位置,并在其中的某个论坛上找到它declare -f
。因此,我想在输出中找到它,但还要再次阅读它。
我有一些想法并尝试了
declare -f | grep blossom
好吧,那只显示了 blossom() {
所以我想,嗯...让我们尝试
declare -f | less
但这仍然太难搜寻了...
关于什么
declare -f > test_file
nano test_file
很好,这确实解决了我要尝试做的一些事情,我可以将其^W用于“ Where at”,并且发现它没有问题。但这会创建一个文件,我不想这样做。
如何使用一组特定的命令来预搜索具有上下滚动功能的输出。也许使用less
命令并进行了预先搜索。这可能吗?
请尝试以下方法开始less
与blossom
已经搜寻:
declare -f | less -p blossom
从以下文档中less
:
-ppattern or --pattern=pattern
The -p option on the command line is equivalent to specifying
+/pattern; that is, it tells less to start at the first occur‐
rence of pattern in the file.
如果您的问题不那么笼统,并且您只想要函数的来源blossom
,请使用以下命令:
declare -f blossom
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句