简体   繁体   中英

how to grab all jpg files recursively using shell scripting

so whenever I put a directory as my first argument, I want my program to grab all the jpg files and sort them in the order they are created. I have more than one sub-directories so I need the process to be done recursively. Here's what I tried

#!/bin/bash
file = "$1"
find $1 -name '*.jpg'
sor...

really not sure how to approach...any help would be appreciated

You give a path and file type,this code find :) You can save as FindFileScript.sh

#!/bin/bash
echo -n "Which directory should I search ? (/Desktop) : "
read directory
echo -n "Select file type(like png || jpg || pdf) : "
read fileType
find "$directory" -type f -name "*.$fileType"
./FindFileScript.sh 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM