且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

查找文件类型

更新时间:2021-12-29 10:01:11


我是新手...这可能是一个基本问题...


在korn shell脚本中,如何找到文件的类型....这里是伪


if(文件名的类型为.eml或.jpg)然后

---提前做某事


thx。
I am newbie... this may be a basic question...

In korn shell script, how to find the type of the file.... here is the pseudo

if (filename is of type ".eml" or ".jpg") then
--- do something

thx in advance.



你有文件名开头吗?你可以发布你的shell脚本吗?

Do you have a filename to begin with? Could you post your shell script thus far?


该目录包含以下文件

.html

.jpg

.css

.js


我只想根据扩展名或某些文件类型逻辑检查.jpg文件。


1)for x in
The directory contains the following files
.html
.jpg
.css
.js

I want only the .jpg files checked based on the extension or some file type logic.

1) for x in


{directory} /*.*

2)if(x endswith .jpg)然后///找到特定类型的文件。

//做点什么


我正在寻找确切的条件(FOR ENDS WITH)如何保持第二行。


thx提前。
{directory}/*.*
2) if (x endswith .jpg) then /// finding a particular type of file.
// do something

I am looking for the exact condition (FOR ENDS WITH) how to keep on the second line.

thx in advance.