mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-06 08:51:14 -03:00
[count] Allow counting lines from stdin
As a simple replacement for `wc -l`. This counts both lines on stdin _and_ arguments. So if "file" has three lines, then `count a b c < file` will print 6. And since it counts newlines, like wc, `echo -n foo | count` prints 0.
This commit is contained in:
@@ -13,3 +13,6 @@
|
||||
|
||||
####################
|
||||
# big counts
|
||||
|
||||
####################
|
||||
# stdin
|
||||
|
||||
@@ -27,3 +27,12 @@ for i in seq 500
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
logmsg stdin
|
||||
# Reading from stdin still counts the arguments
|
||||
printf '%s\n' 1 2 3 4 5 | count 6 7 8 9 10
|
||||
|
||||
# Reading from stdin counts newlines - like `wc -l`.
|
||||
echo -n 0 | count
|
||||
|
||||
echo 1 | count
|
||||
|
||||
@@ -21,3 +21,9 @@
|
||||
|
||||
####################
|
||||
# big counts
|
||||
|
||||
####################
|
||||
# stdin
|
||||
10
|
||||
0
|
||||
1
|
||||
|
||||
Reference in New Issue
Block a user