LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1094|回复: 8

又一周一练,请大家来交流一下

[复制链接]
发表于 2004-3-12 08:12:44 | 显示全部楼层 |阅读模式
Write a single command to accomplish the following goals:


1.Remove all files with file names longer than five characters

2.Find all files that end in the extension “.cpp” and create a of each, in the same directory, with the same name appended with “.backup”.  For example, if you find “~/code/helloWorld.cpp” you should create “~/code/helloWorld.cpp.backup”

3.Make a complete copy of your home directory (and all subdirectories inside, recursively) into the /temp directory.




Write Regular Expressions that match strings of the following criteria:


1. Any string that begins with an ‘a’, ends with an ‘a’, and contains anything except ‘a’s in-between.

2. Any string that contains three digits, next to each other, or not next to each other.

3. Any string that begins with a vowel (a, e, i, o, or u, never mind y), capital or lowercase.
发表于 2004-3-12 14:24:31 | 显示全部楼层
1,rm ?????*
2,for file $(ls *.cpp);do mv $file $file.backup;done
3,cp -dpR /home /temp
1,^a[b-z]*a$
2,[0-9]\{3\}
3,?
 楼主| 发表于 2004-3-13 05:21:50 | 显示全部楼层
谢谢.

^[aeiouyAEIOUY]  这样可以吗?
^ 代表开头的, aeiouy 的大小写都在[ ] 里了^_^
发表于 2004-3-13 12:34:55 | 显示全部楼层
never mind y
这是什么意思?
发表于 2004-3-13 12:59:37 | 显示全部楼层
觉得这个不太对:
1,^a[b-z]*a$
因为当中的字符不一定都是小写字母
我觉得类似于这个
\<a[^a]*a\>
明天找机器试一下,呵呵
 楼主| 发表于 2004-3-14 01:41:37 | 显示全部楼层
最初由 javalee 发表
never mind y
这是什么意思?


v.
没关系, 不用担心.

我是想,y 是付合条件的.
 楼主| 发表于 2004-3-16 09:50:24 | 显示全部楼层
1.  rm ?????*
2.  find ~ -name \*.cpp|sed -e s/cpp/cpp\.back/|xargs touch
3,  cp -dpR /home /temp

1,  ^a[b-z]*a$
2,  [0-9]{3}
3,  ^[aeiouyAEIOUY].*

不知这样做对不对.
发表于 2004-4-11 11:27:45 | 显示全部楼层
1.还可以  ls | grep ".\{5,\}" | xarg rm -f
发表于 2008-6-25 15:10:23 | 显示全部楼层
Thank you for sharing
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

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