extracting number of rows

if

> wc -l data.txt
> 100

(meaning there are 100 rows)

i want to assgn 100 as n so that if i do

>echo n

it would give me

 100

Thanks

Like this?

n=$(wc -l < data.txt)
1 Like
bash-3.2$ n= $(wc -l < ${data}/index_new)
bash: 3758: command not found

i got this...

try:

n=($(wc data.txt))

I hadn't put a space after the = . Why did you? Drop that space.

@johnkim0806: I don't know how many reminders you need before it sinks in that we'd appreciate it if you'd use code tags.