Créer un site internet

Unix/Linux

How to list file names within a folder based on a pattern?

If you want to search for files with name containing "*pattern*" in all subdirectories:

find /path/to/folder -type f -name "*pattern*"

And to search to a certain depth "alpha" of subdirectories use the following command:

find /path/to/folder -maxdepth alpha -type f -name "*pattern*"

Count number of files in directory

find . -type f | wc -l

Explanation:
find . -type f finds all files ( -type f ) in this ( . ) directory and in all sub directories, the filenames are then printed to standard out one per line.

This is then piped | into wc (word count) the -l option tells wc to only count lines of its input.

Together they count all your files.

Finding of the process using a specific port

$ sudo ss -lptn 'sport = :80'
State   Local Address:Port  Peer Address:Port              
LISTEN  127.0.0.1:80        *:*                users:(("mhi",pid=125004,fd=12))

- You can also use the same invocation you're currently using:

$ sudo netstat -nlp | grep :80
tcp  0  0  0.0.0.0:80  0.0.0.0:*  LISTEN  125004/mhi

-You can also use lsof:

$ sudo lsof -n -i :80 | grep LISTEN
nginx   125004 mhi    3u  IPv4   6645      0t0  TCP 0.0.0.0:80 (LISTEN)