find only latest hdfs files from directory
I would like to find out the latest files from hdfs directory and keep them as it is and delete older files.
I have 4 files in hdfs directory /user/hive/warehouse/test :
-rwxrwx--x+ 3 hive hive 9 2018-11-13 04:13 /user/hive/warehouse/test/bc4151c16c98d191-72314e2e00000000_640731000_data.0.
-rwxrwx--x+ 3 hive hive 9 2018-11-13 04:35 /user/hive/warehouse/test/bc4151c16c98d191-72314e2e00000000_640731001_data.0.
-rwxrwx--x+ 3 hive hive 12 2018-11-13 08:31 /user/hive/warehouse/test/944adb43a3a5f955-659ed0e100000000_916442110_data.0.
-rwxrwx--x+ 3 hive hive 12 2018-11-13 08:31 /user/hive/warehouse/test/944adb43a3a5f955-659ed0e100000000_916442111_data.0.
I want to delete all files which are not latest.
That means my directory should contain the files with timestamp 2018-11-13 08:31
I can sort those files using hdfs dfs -ls /user/hive/warehouse/test | sort -k6,7
How to delete older files? hdfs commands do not have the command like find which would extract only the latest files.
unix hadoop hdfs hadoop2
add a comment |
I would like to find out the latest files from hdfs directory and keep them as it is and delete older files.
I have 4 files in hdfs directory /user/hive/warehouse/test :
-rwxrwx--x+ 3 hive hive 9 2018-11-13 04:13 /user/hive/warehouse/test/bc4151c16c98d191-72314e2e00000000_640731000_data.0.
-rwxrwx--x+ 3 hive hive 9 2018-11-13 04:35 /user/hive/warehouse/test/bc4151c16c98d191-72314e2e00000000_640731001_data.0.
-rwxrwx--x+ 3 hive hive 12 2018-11-13 08:31 /user/hive/warehouse/test/944adb43a3a5f955-659ed0e100000000_916442110_data.0.
-rwxrwx--x+ 3 hive hive 12 2018-11-13 08:31 /user/hive/warehouse/test/944adb43a3a5f955-659ed0e100000000_916442111_data.0.
I want to delete all files which are not latest.
That means my directory should contain the files with timestamp 2018-11-13 08:31
I can sort those files using hdfs dfs -ls /user/hive/warehouse/test | sort -k6,7
How to delete older files? hdfs commands do not have the command like find which would extract only the latest files.
unix hadoop hdfs hadoop2
What have you tried? With what do you have problem? What does not work? If you search for someone to do the job for you, try freelancing sites. You may read how to ask a good quesiton.there can be multiple files with latest timestamps
With what resolution? With minutes resolution? Also, you may intereset yourself in this thread.
– Kamil Cuk
Nov 13 '18 at 14:30
Let's consider I have 5 files with timestamp as "2018-11-13 08:31". I want to keep them only and delete rest files. Link you have referred has used head command. In my case, I cannot use head command.
– Cast_A_Way
Nov 13 '18 at 14:35
Possible duplicate of How to recursively find and list the latest modified files in a directory with subdirectories and times?
– VIN
Nov 13 '18 at 14:35
1
I am using hdfs commands. Find command is not available in hdfs commands.
– Cast_A_Way
Nov 13 '18 at 14:39
add a comment |
I would like to find out the latest files from hdfs directory and keep them as it is and delete older files.
I have 4 files in hdfs directory /user/hive/warehouse/test :
-rwxrwx--x+ 3 hive hive 9 2018-11-13 04:13 /user/hive/warehouse/test/bc4151c16c98d191-72314e2e00000000_640731000_data.0.
-rwxrwx--x+ 3 hive hive 9 2018-11-13 04:35 /user/hive/warehouse/test/bc4151c16c98d191-72314e2e00000000_640731001_data.0.
-rwxrwx--x+ 3 hive hive 12 2018-11-13 08:31 /user/hive/warehouse/test/944adb43a3a5f955-659ed0e100000000_916442110_data.0.
-rwxrwx--x+ 3 hive hive 12 2018-11-13 08:31 /user/hive/warehouse/test/944adb43a3a5f955-659ed0e100000000_916442111_data.0.
I want to delete all files which are not latest.
That means my directory should contain the files with timestamp 2018-11-13 08:31
I can sort those files using hdfs dfs -ls /user/hive/warehouse/test | sort -k6,7
How to delete older files? hdfs commands do not have the command like find which would extract only the latest files.
unix hadoop hdfs hadoop2
I would like to find out the latest files from hdfs directory and keep them as it is and delete older files.
I have 4 files in hdfs directory /user/hive/warehouse/test :
-rwxrwx--x+ 3 hive hive 9 2018-11-13 04:13 /user/hive/warehouse/test/bc4151c16c98d191-72314e2e00000000_640731000_data.0.
-rwxrwx--x+ 3 hive hive 9 2018-11-13 04:35 /user/hive/warehouse/test/bc4151c16c98d191-72314e2e00000000_640731001_data.0.
-rwxrwx--x+ 3 hive hive 12 2018-11-13 08:31 /user/hive/warehouse/test/944adb43a3a5f955-659ed0e100000000_916442110_data.0.
-rwxrwx--x+ 3 hive hive 12 2018-11-13 08:31 /user/hive/warehouse/test/944adb43a3a5f955-659ed0e100000000_916442111_data.0.
I want to delete all files which are not latest.
That means my directory should contain the files with timestamp 2018-11-13 08:31
I can sort those files using hdfs dfs -ls /user/hive/warehouse/test | sort -k6,7
How to delete older files? hdfs commands do not have the command like find which would extract only the latest files.
unix hadoop hdfs hadoop2
unix hadoop hdfs hadoop2
edited Nov 13 '18 at 20:27
James Z
11.1k71835
11.1k71835
asked Nov 13 '18 at 14:15
Cast_A_WayCast_A_Way
379416
379416
What have you tried? With what do you have problem? What does not work? If you search for someone to do the job for you, try freelancing sites. You may read how to ask a good quesiton.there can be multiple files with latest timestamps
With what resolution? With minutes resolution? Also, you may intereset yourself in this thread.
– Kamil Cuk
Nov 13 '18 at 14:30
Let's consider I have 5 files with timestamp as "2018-11-13 08:31". I want to keep them only and delete rest files. Link you have referred has used head command. In my case, I cannot use head command.
– Cast_A_Way
Nov 13 '18 at 14:35
Possible duplicate of How to recursively find and list the latest modified files in a directory with subdirectories and times?
– VIN
Nov 13 '18 at 14:35
1
I am using hdfs commands. Find command is not available in hdfs commands.
– Cast_A_Way
Nov 13 '18 at 14:39
add a comment |
What have you tried? With what do you have problem? What does not work? If you search for someone to do the job for you, try freelancing sites. You may read how to ask a good quesiton.there can be multiple files with latest timestamps
With what resolution? With minutes resolution? Also, you may intereset yourself in this thread.
– Kamil Cuk
Nov 13 '18 at 14:30
Let's consider I have 5 files with timestamp as "2018-11-13 08:31". I want to keep them only and delete rest files. Link you have referred has used head command. In my case, I cannot use head command.
– Cast_A_Way
Nov 13 '18 at 14:35
Possible duplicate of How to recursively find and list the latest modified files in a directory with subdirectories and times?
– VIN
Nov 13 '18 at 14:35
1
I am using hdfs commands. Find command is not available in hdfs commands.
– Cast_A_Way
Nov 13 '18 at 14:39
What have you tried? With what do you have problem? What does not work? If you search for someone to do the job for you, try freelancing sites. You may read how to ask a good quesiton.
there can be multiple files with latest timestamps
With what resolution? With minutes resolution? Also, you may intereset yourself in this thread.– Kamil Cuk
Nov 13 '18 at 14:30
What have you tried? With what do you have problem? What does not work? If you search for someone to do the job for you, try freelancing sites. You may read how to ask a good quesiton.
there can be multiple files with latest timestamps
With what resolution? With minutes resolution? Also, you may intereset yourself in this thread.– Kamil Cuk
Nov 13 '18 at 14:30
Let's consider I have 5 files with timestamp as "2018-11-13 08:31". I want to keep them only and delete rest files. Link you have referred has used head command. In my case, I cannot use head command.
– Cast_A_Way
Nov 13 '18 at 14:35
Let's consider I have 5 files with timestamp as "2018-11-13 08:31". I want to keep them only and delete rest files. Link you have referred has used head command. In my case, I cannot use head command.
– Cast_A_Way
Nov 13 '18 at 14:35
Possible duplicate of How to recursively find and list the latest modified files in a directory with subdirectories and times?
– VIN
Nov 13 '18 at 14:35
Possible duplicate of How to recursively find and list the latest modified files in a directory with subdirectories and times?
– VIN
Nov 13 '18 at 14:35
1
1
I am using hdfs commands. Find command is not available in hdfs commands.
– Cast_A_Way
Nov 13 '18 at 14:39
I am using hdfs commands. Find command is not available in hdfs commands.
– Cast_A_Way
Nov 13 '18 at 14:39
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53282997%2ffind-only-latest-hdfs-files-from-directory%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53282997%2ffind-only-latest-hdfs-files-from-directory%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What have you tried? With what do you have problem? What does not work? If you search for someone to do the job for you, try freelancing sites. You may read how to ask a good quesiton.
there can be multiple files with latest timestamps
With what resolution? With minutes resolution? Also, you may intereset yourself in this thread.– Kamil Cuk
Nov 13 '18 at 14:30
Let's consider I have 5 files with timestamp as "2018-11-13 08:31". I want to keep them only and delete rest files. Link you have referred has used head command. In my case, I cannot use head command.
– Cast_A_Way
Nov 13 '18 at 14:35
Possible duplicate of How to recursively find and list the latest modified files in a directory with subdirectories and times?
– VIN
Nov 13 '18 at 14:35
1
I am using hdfs commands. Find command is not available in hdfs commands.
– Cast_A_Way
Nov 13 '18 at 14:39