bash - Wc and reading from a file -


i want check number of lines of file without using temporary file using wc. tried using this: var=${wc -l a.txt} or wc -l a.txt | read line both didn't work.

the way store output of command var=$(command) instead of var=${command} used.

hence, do:

var=$(wc -l a.txt)    # returns xx a.txt 

to store number, do

var=$(wc -l < a.txt)  # returns xx             ^ 

Comments

Popular posts from this blog

android - Inheriting from Theme.AppCompat* -

broadcastreceiver - android BOOT_COMPLETED not received if not activity intent-filter -

basic authentication with http post params android -