7/4/2023 0 Comments Ls grep file extensionTells grep to only let the filenames that end with the extension. This filename extension search pattern: \.html$ Perl filename globbing - The filename search pattern Opendir(DIR, = grep(/\.html$/,readdir(DIR)) Īs you can see, this Perl code looks in the current directory then, as it reads the files in the current directory the grep function only passes the filenames along that match the filename pattern (regex) we supplied. Summary: A quick Perl tip on how to list all files in a directory that match a given filename pattern, i.e., using the Perl filename "glob" pattern-matching syntax.Īs a quick tip today, here's some sample Perl code that prints a listing of every file in the current directory that ends with the filename extension.
0 Comments
Leave a Reply. |