linux - linux终端中的随机文本

标签 linux bash terminal debian

伙计们。如何让终端显示我想要的文本?以及如何编辑已经显示的文本 例如终端现在显示:

user@host: sudo writetext 
bash: writetext: command not found

如何编辑这段文字使其显示成这样

user@host: sudo writetext  5
 writelext line 1 executed
 writelext line 2 executed
 writelext line 3 executed
 writelext line 4 executed
 writelext line 5 executed

我不需要程序运行,我只需要知道如何在终端中显示随机文本

最佳答案

你可以给bashrc添加一个别名

  1. vim ~/.bashrc
  2. 转到文件末尾
  3. 添加行:alias writeText='echo "write text executed"'
  4. 然后重新加载 bashrc:source ~/.bashrc

在此之后,您应该可以通过键入 writeText

来调用别名

在这里您还可以添加更高级的回显功能。

如果你想传递参数,你必须编写一个单独的函数,如下所述: Passing argument to alias in bash

关于linux - linux终端中的随机文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44675655/

相关文章:

linux - Linux 中的 WCHAN=unix_s

c - 如何将 C-printf 字符串格式化为等于 bash-printf 字符串

bash - 如何在 bash 脚本中传递多个参数以提示?

与 Windows 相比,Linux 上的代码速度较慢

linux - float 在 perl 的德语语言环境中不是逗号分隔的

linux - 如何打印我的 txt 文件第一列的前 20 行特定行?

Java 进程流

string - BS4 : "soup.title.string" doesn't work on IDLE but Terminal

linux - 在 sed 中使用 ' *' 时所有内容都被删除

linux - 多变量定义和赋值