Wednesday, December 19, 2018

Count directories with Windows command line

cd C:\Foo

REM Foo contains 2 files and 3 folders
dir /b
file1.txt
file2.txt
Folder1
Folder2
Folder3

REM Filter out files and '.' and '..' folders
for /f %i in ('dir /b /ad-s-h ^| find /i /v /c ""') do @echo %i
3

Tuesday, September 11, 2018

Perl: How to capture a regex match in one line

my ($match) = "some string" =~ /(some).*/;
print $match; # prints "some"