Can anyone explain to me how does this command work.
wc -l `ls`
while this command gives the total number of java lines or txt lines.
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
ls outputs a list of file/directory names in the current directory.
`ls` will be replaced by the output of
ls. So you're actually running something like:
wc -l file1 file2 file3 ... fileN
And of course
wc will open each file named in the command line in turn, to count the lines.
The same effect could be had by running:
wc -l *
Note that this only holds if none of the file names in the current directory contain any “weird” character (whitespace or