سؤال

To get total number of lines read, why we are using ls -la | script.sh ?
Why we cant execute normal way like script.sh ?
Note that script.sh is the shell script program.

هل كانت مفيدة؟

المحلول

Breaking it down bit by bit:

ls -la

List all files (including dotfiles) in long format.

|

Sends the output of the command on the left to the command on the right

script.sh

Executes the script.

So the output of ls -la will be sent via stdin to script.sh.

نصائح أخرى

To get total number of lines, that is files in your case, simply

ls | wc -l
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top