![](/img/trans.png)
[英]How can I execute an MySQL command through a shell script using if -else for condition based?
[英]How can I execute a command and store the files in a folder using a shell script?
我有大量的 tif 文件。
a.tif
b.tif
axx.tif
auw.tif
我正在尝试编写一个脚本
在名为“subdir”的子目录下存储具有相同文件名的新文件
#!/bin/csh list - ls *.tif for file in list gdalwarp -t_srs EPSG:4269 -te -130 20 -60 55 -tr 0.01 -0.01 oldfilename.tif subdir/oldfilename.tif
完毕
我怎样才能做到这一点?
您可以使用“find”命令,而不是使用“list”来查找文件,它是如何完成的:
find . -name "*.tif" -exec gdalwarp -t_srs EPSG:4269 -te -130 20 -60 55 -tr 0.01 -0.01 {} subdir/{} \;
解释:
这 。 代表“当前目录” -name 选项搜索名称与给定模式匹配的文件。
-exec 选项用于使用找到的文件“find”运行命令。 {} 代表找到的“文件名”,必须运行的命令后面需要跟 \\;
我强烈建议您阅读 find 的手册条目,并在尝试编写 shell 脚本时对您可以使用的工具进行更多研究。
问候!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.