Grep for filetype starting with letter p

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

  1. The problem statement, all variables and given/known data:
  1. Which files in /usr/bin whose names begin with �p� are python scripts? Store the numbered results in python_scripts.txt.
  1. Relevant commands, code, scripts, algorithms:
    See below?

  2. The attempts at a solution (include all code and scripts):
    find /usr/bin -type f -exec ls -na {} \; | grep "^p" | less

So i know that the ^ should be giving me the file starting with p but its not... and im not sure what or how to determine that a file is a python file... .py?

Could i use ls -X to get the files listed by file extension?

  1. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
    Keene state KSC Keene NH USA Chalire Wilder CS125-01

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).

I think this is what your trying to accomplish. This assumes the python scripts have an .py suffix.

ls /usr/bin/p*.py|wc -l
1 Like

Yeah i managed to get it this way find /usr/bin -type f -name "*.py" but i was trying to grep for the files starting with p, i didnt think to add it to the find.

Thanks!

if you want to use find do this.

find /usr/bin -type f -name "p*.py"
1 Like