0

I would like to know if we can list files in an HDFS directory with files NOT matching the given pattern.

For instance, assume I have some files with names containing some date values [eg: 'file201606250001.csv'].

If I need to get list of files not belonging to a date pattern, say '*20160629*', what command can I use?

I tried to give the following command, but it still is listing all files (including the ones matching the pattern I wanted to exclude).

hdfs dfs -ls /test/* | grep -v '*20160629*'

I tried the solution given here, but still it returns all files.

Community
  • 1
  • 1
Hrishikesh
  • 47
  • 1
  • 13

1 Answers1

1

First list the file and then grep other than your pattern (-v option)

hadoop fs -ls /dir/path/to/search |grep -v '20160629'

Ronak Patel
  • 3,819
  • 1
  • 16
  • 29