Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

about hadoop fs test command output

Tags:

hadoop

I am running below command, tried to use either filename exists, or filename not exists, but none of them have any outputs from console. I expect if a file exists, the command should return zero?

http://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-common/FileSystemShell.html#test

hadoop fs -test -e filename
like image 958
Lin Ma Avatar asked Dec 03 '25 13:12

Lin Ma


2 Answers

I think it means the return code of the command is 0.

You can check with

hadoop fs -test -e filename
echo $?
like image 85
OneCricketeer Avatar answered Dec 06 '25 06:12

OneCricketeer


Try

hadoop fs -test -d <HDFSFilename>

You should see test: File does not exists

If the file does not exists - and a blank string if it does

1=$(hadoop fs test -d <HDFSFilename>)

I am sure you are using a HDFS filename and not a Linux based filename - but best check

hadoop fs -ls /
like image 37
Tim Seed Avatar answered Dec 06 '25 04:12

Tim Seed



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!