Just starting out with bash and I’m having a little trouble getting this script to work. I’m wanting it to list the contents of a directory and output only certain file types to a .txt.
An example of what I’ve got so far when trying to list only .pdf, .txt and .doc files is below, just wondering where about I’ve gone wrong?
#!/bin/bash
ls -a | grep -vi '*.(pdf|txt|doc)$' $1 > contents.txt
By the way, you can do this without
grepand regex, i.e.