It is required to count the total number of lines in txt
files lying in the directory whose name is specified by the script parameter.
#! /bin/bash A1=cat/A1 | grep '\.txt$'| wc -l echo $A1
What to do to make it work?
It is required to count the total number of lines in txt
files lying in the directory whose name is specified by the script parameter.
#! /bin/bash A1=cat/A1 | grep '\.txt$'| wc -l echo $A1
What to do to make it work?
#! /bin/bash
if you are using shebang , its syntax does not provide spaces in this place.
and the script might look something like this:
#!/bin/bash cat $1/*.txt | wc -l
or, if you want to save (and then print) the number of lines in a variable:
#!/bin/bash k=$(cat $1/*.txt | wc -l) echo $k
!
. The phrase "Blanks after! Are OK" is even present in the English version of the article from Wikipedia to which you referred (quote from Dennis Ritchie - the person who added shebang in Unix). Is space allowed between #!
and /bin/bash
in shebang? And on modern systems, spaces are resolved. - jfsZache through the conveyor immediately, you can directly:
~$ wc -l ./* 3 ./abc.txt 0 ./big-file 1 ./test1 4 total
Source: https://ru.stackoverflow.com/questions/233456/
All Articles
cat *.txt | wc -l
cat *.txt | wc -l
; echo $ a1 - avpcat $1/*.txt | wc -l
cat $1/*.txt | wc -l
Otherwise, it is possible #! / bin / sh cat $ 1 / *. txt | sed -ne '$ =' - alexlz