简体   繁体   English

我如何在终端中回显字符串+命令

[英]How can i echo string + command in terminal

how can i 'echo' this command(NUMBER lines in my script): 我如何“回显”此命令(脚本中的NUMBER行):

Number of lines is 23.

Code: 码:

#!/bin/bash
.
.
.
.
echo Number of line is cat $0 | wc -l
.
.
.
.

This should do the trick. 这应该可以解决问题。

#!/bin/bash

echo "This script is `wc -l $0 | cut -d " " -f 1` lines long."

尝试

echo "Number of line is `wc -l < $0`"

这是另一种解决方案

 grep -c ^  [FILENAME]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用命令或部分命令预填充终端提示符? - How can I prepopulate a terminal prompt with a command or partial command? Linux 终端 - 任何人都可以分解这个 echo 命令吗? - Linux Terminal - Can anyone break down this echo command? 如何使用 Javascript 在终端命令行中传递 arguments? - How can I pass arguments in the terminal command line using Javascript? 如何使用 Python 异步运行终端命令? - How can I run a terminal command asynchronously using Python? 如何在不使用空间的情况下在 linux 终端中执行命令? - How i can execute command in linux terminal without using space? 如何通过python绕过命令到另一个终端内部的终端? - How can I bypass a command to terminal inside another terminal via python? 带变量和字符串的echo命令 - echo command with variable and string 在终端“ echo”中,如何匹配Brace表达式? - In Terminal “echo”, how do I get to Brace expressions to match? 为什么我可以在 linux 终端中运行 flutter 命令,但不能在 vscode 终端中运行? - Why i can run flutter command in linux terminal, but not in vscode terminal? 如何使用execl()函数或其他类型的exec()函数执行echo命令? - How can I use execl() function or other kinds of exec() functions to perform echo command?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM