Indranil Ganguly Indranil Ganguly - 3 months ago 9
Bash Question

File Renaming in HDFS

i am putting a particular file in hdfs directory with name A1 and want to do this process multiple times while running my shell script, but when i put the file in hdfs directory i want to rename that A1 file and every time renaming should be different how can i do this .

scenario: I am having a file name A1 and once all the operation is done that file i am keeping in hdfs directory name completed_data, as i am running this using shell script and scheduler this process will happen after an interval that time i same file name A1 cannot exist in same directory so i want to rename A1 every time with different names.



I am giving examples of normal mv. You can change it for your hadoop environment.

Using $RANDOM (as commented by @Backtrack ):

mv A1 A1_${RANDOM}

Using date command:

mv A1 A1_$(date +%N)

Using mktemp:

mv A1 $(mktemp --tmpdir=/dir/where/you/want A1_XXX)