SHELL命令
来源:互联网 发布:做淘宝加盟要多少钱 编辑:程序博客网 时间:2024/06/08 06:46
基本的命令不多讲:
basename 用途
返回一个字符串参数的基本文件名称。
语法
basename String [ Suffix ]
描述
basename 命令读取 String 参数,删除以 /(斜杠) 结尾的前缀以及任何指定的 Suffix 参数,并将剩余的基本文件名称写至标准输出。basename 命令应用以下创建基本文件名称的规则:
如果 String 参数是 //(双斜杠) 或如果 String 参数包含的都是斜杠字符,则将字符串更改为单个 /(斜杠)。跳过步骤 2 到 4。
从指定字符串除去任何拖尾的 / 字符。
如果在 String 参数中剩余任何 / 字符,则除去字符串的前缀直到(包含)最后一个 / 字符。
如果指定 Suffix 参数,且它和字符串中的剩余的字符相同,则不修改此字符串。例如,输入:
basename /home/oracle/1.txt 1.txt
结果是: 1.txt
如果指定 Suffix 参数,且它和字符串中所有字符都不相同,但和字符串的后缀相同,则除去指定后缀。例如,输入:
basename /home/oracle/1.txt .txt
结果是:1
测试:
>[/home/service/hs/temp]$basename 1.txt.old1.txt.old>[/home/service/hs/temp]$basename /1/1.txt.old1.txt.old>[/home/service/hs/temp]$basename /home/home///// 1home>[/home/service/hs/temp]$basename /home/home1//// 1home>[/home/service/hs/temp]$basename /home/home1 1home>[/home/service/hs/temp]$basename /home/home1 2home1>[/home/service/hs/temp]$basename /home/home1 1 2 basename: too many argumentsTry `basename --help' for more information.>[/home/service/hs/temp]$basename /home/home1/123/ 312>[/home/service/hs/temp]$basename /home/home1/124/ 3124目录下有同名的文件
1.c 1.o 1.x
用命令重名成
1.c.bak 1.o.bak 1.x.bak
>[/home/service/hs/temp]$find . -name "1.[cox]" |xargs -i basename {}|xargs -t -i mv {} {}.bakmv 1.c 1.c.bakmv 1.o 1.o.bakmv 1.x 1.x.bak
0 0
- shell命令
- shell命令
- shell命令
- Shell命令
- shell命令:
- Shell命令
- shell命令
- shell命令
- shell命令
- shell 命令
- shell 命令
- shell命令
- shell 命令
- SHELL命令
- shell命令
- shell 命令
- Shell 命令
- Shell 命令
- poj 1426 Find The Multiple
- zoj 3706 Break Standard Weight
- 嵌入式 Makefile中:=与?=与+=与=的区别$@,$^,$<区别
- 学习新技术的10个建议
- unity中虚拟直升机、直升机的旋转移动,子弹的实例化爆炸等效果的实现
- SHELL命令
- 华为牛人的十年工作感悟
- Nodejs完成一个待办事项的实例教程
- Unity的设计模式--单例模式,
- Timer和TimerTask
- 汉诺塔的原理剖析以及递归的解决办法
- JS固定表头及固定左边列
- Servlet FileNotFoundException 解决方案
- SEO高质量的伪原创怎么写?