user4156778
user4156778

Reputation:

How can i echo string + command in terminal

how can i 'echo' this command(NUMBER lines in my script):

Number of lines is 23.

Code:

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

Upvotes: 3

Views: 9210

Answers (3)

Adem Öztaş
Adem Öztaş

Reputation: 21446

This is an another solution

 grep -c ^  [FILENAME]

Upvotes: 0

fweik
fweik

Reputation: 451

This should do the trick.

#!/bin/bash

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

Upvotes: 5

SMA
SMA

Reputation: 37023

Try

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

Upvotes: 0

Related Questions