For a school project, I have to SSH into a folder on the school server, the usr/bin folder which has a list of files, then print a list of files that start with "file". I know Regex half-decently, at least conceptually, but I'm not sure of the UNIX command to do this.
I tried grep '^[file][a-zA-Z0-9]*'
(start of a line, letters f-i-l-e, then 0 or more occurrences of any other number or digit) but that doesn't seem to work.
Help?
You can use find
command for this once you are connected to your school server.
find /usr/bin -type f -name "file*"
How would I do it if I wanted all files that started with a OR b, and ended with a OR b
find /usr/bin -type f -regex "^[ab].*[ab]$"
ls
and grep
:ls -1 /usr/bin | grep "^[ab].*[ab]$"
You should be able to use a simple ls command to get this information.
cd /usr/bin
ls -1 file*
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With