找回密码
 注册
搜索
[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
查看: 18706|回复: 4

[问题求助] 以文件名为条件建立文件夹的shell脚本编写

[复制链接]
发表于 2012-6-4 16:23:29 | 显示全部楼层 |阅读模式
http://bbs.bathome.net/viewthrea ... mp;extra=#pid109951

链接处的内容是win平台的问题,现已在4#得到了解决。
由初期的for循环中的delims问题最终定位到%%~na的有效应用,实现了问题的最终解决。

此帖是将思维扩展一下,到了linux平台下,结合链接处1#的具体内容,大家可否写一下脚本代码。
发表于 2012-7-10 16:54:14 | 显示全部楼层
  1. [seesea@bathome test]$ echo "aa" > atimetool_1.9.6.deb
  2. [seesea@bathome test]$ echo "aa" > atimetool_1.9.7.deb
  3. [seesea@bathome test]$ ls
  4. atimetool_1.9.6.deb  atimetool_1.9.7.deb
  5. [seesea@bathome test]$ for f in *; do mkdir ${f/.deb/} && mv $f ${f/.deb/}; done;
  6. [seesea@bathome test]$ ls
  7. atimetool_1.9.6  atimetool_1.9.7
  8. [seesea@bathome test]$ ls *
  9. atimetool_1.9.6:
  10. atimetool_1.9.6.deb

  11. atimetool_1.9.7:
  12. atimetool_1.9.7.deb
  13. [seesea@bathome test]$ for d in *; do mv $d/* .; rm -rf $d; done;
  14. [seesea@bathome test]$ ls
  15. atimetool_1.9.6.deb  atimetool_1.9.7.deb
复制代码
发表于 2012-7-10 16:54:59 | 显示全部楼层

  1. # 移入目录
  2. [seesea@bathome test]$ for f in *; do mkdir ${f/.deb/} && mv $f ${f/.deb/}; done;
  3. # 移出目录
  4. [seesea@bathome test]$ for d in *; do mv $d/* .; rm -rf $d; done;
复制代码
 楼主| 发表于 2012-12-12 09:31:06 | 显示全部楼层
谢谢楼上两位,我得消化一阵,shell脚本的功底还是不太好。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|批处理之家 ( 渝ICP备10000708号 )

GMT+8, 2026-3-17 03:48 , Processed in 0.017629 second(s), 8 queries , File On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表