在测试hadoop的dfs的各种命令的时候,突然发现dfs -rmr支持通配符操作(前提是要在hadoop的bin目录下执行)
补充点:ls cat也支持通配符的
例如执行ls后有如下文件
- [dikar@dikar ~]$ hadoop dfs -ls
- opts= -Dhadoop.log.dir=/home/dikar/Program/hadoop-0.20 . 2 /bin/../logs -Dhadoop.log.file=hadoop.log -Dhadoop.home.dir=/home/dikar/Program/hadoop- 0.20 . 2 /bin/.. -Dhadoop.id.str= -Dhadoop.root.logger=INFO,console -Djava.library.path=/home/dikar/Program/hadoop- 0.20 . 2 /bin/../lib/native/Linux-i386- 32 -Dhadoop.policy.file=hadoop-policy.xml
- class =org.apache.hadoop.fs.FsShell
- params=-ls
- Found 3 items
- -rw-r--r-- 2 dikar supergroup 622 2011 - 03 - 05 16 : 55 /user/dikar/ta
- -rw-r--r-- 2 dikar supergroup 9 2011 - 03 - 05 16 : 51 /user/dikar/test1
- -rw-r--r-- 2 dikar supergroup 10 2011 - 03 - 05 16 : 51 /user/dikar/test2
然后执行rmr test*
- [dikar@dikar bin]$ hadoop dfs -rmr test*
- opts= -Dhadoop.log.dir=/home/dikar/Program/hadoop-0.20 . 2 /bin/../logs -Dhadoop.log.file=hadoop.log -Dhadoop.home.dir=/home/dikar/Program/hadoop- 0.20 . 2 /bin/.. -Dhadoop.id.str= -Dhadoop.root.logger=INFO,console -Djava.library.path=/home/dikar/Program/hadoop- 0.20 . 2 /bin/../lib/native/Linux-i386- 32 -Dhadoop.policy.file=hadoop-policy.xml
- class =org.apache.hadoop.fs.FsShell
- params=-rmr test*
- Deleted hdfs://dikar:54310 /user/dikar/test1
- Deleted hdfs://dikar:54310 /user/dikar/test2
在用ls 查看
- [dikar@dikar bin]$ hadoop dfs -ls
- opts= -Dhadoop.log.dir=/home/dikar/Program/hadoop-0.20 . 2 /bin/../logs -Dhadoop.log.file=hadoop.log -Dhadoop.home.dir=/home/dikar/Program/hadoop- 0.20 . 2 /bin/.. -Dhadoop.id.str= -Dhadoop.root.logger=INFO,console -Djava.library.path=/home/dikar/Program/hadoop- 0.20 . 2 /bin/../lib/native/Linux-i386- 32 -Dhadoop.policy.file=hadoop-policy.xml
- class =org.apache.hadoop.fs.FsShell
- params=-ls
- Found 1 items
- -rw-r--r-- 2 dikar supergroup 622 2011 - 03 - 05 16 : 59 /user/dikar/ta
更多信息请查看 java进阶网 http://www.javady.com