I found this question and tried the solution given (accepted)
However, it didn't really work as expected.
$ cat ports.list 21 22 23 25 $
Instead of scanning the ports in the file, nmap assume those ports as part of the host. See output below.
$ nmap 127.0.0.1 -vvv -p `cat ports.list` Starting Nmap Initiating Ping Scan at 10:50 Scanning 4 hosts [2 ports/host] Completed Ping Scan at 10:50, 1.22s elapsed (4 total hosts) Nmap scan report for 22 (0.0.0.22) [host down, received no-response] Nmap scan report for 23 (0.0.0.23) [host down, received no-response] Nmap scan report for 25 (0.0.0.25) [host down, received no-response] Initiating Connect Scan at 10:50 Scanning localhost (127.0.0.1) [1 port] Completed Connect Scan at 10:50, 0.00s elapsed (1 total ports) Nmap scan report for localhost (127.0.0.1) Host is up, received conn-refused (0.000059s latency). Scanned for 1s PORT STATE SERVICE REASON 21/tcp closed ftp conn-refused Read data files from: /usr/bin/../share/nmap Nmap done: 4 IP addresses (1 host up) scanned in 1.28 seconds $
Is it possible to take a list of ports to scan from a file?