Extract Dump Files Files Names
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I'm trying to automate a database refresh but, now I'm stuck at a part trying to extract the dump files filename to use it with the IMPDP command.
The thing is that we use this parameter doing the export:
dumpfile=dbname_env_date_%u.dmp and a 16-degree parallelism, which creates 16 files like this:
dbname_env_date_01.dmp
dbname_env_date_02.dmp
.
.
.
dbname_env_date_16.dmp
What I'm trying to do is to just extract this "dbname_env_date", so I can use that parameter when importing into another env database.
What I've got so far is this:
dump_filename=$(ls -tr *.dmp | tail -1)
which gives me something like this:
dbname_env_date_16.dmp
and I want it to use later like this:
imdp ' / as sysdba ' dumpfile=$dump_filename_u%.dmp
linux scripting oracle-database
add a comment |Â
up vote
0
down vote
favorite
I'm trying to automate a database refresh but, now I'm stuck at a part trying to extract the dump files filename to use it with the IMPDP command.
The thing is that we use this parameter doing the export:
dumpfile=dbname_env_date_%u.dmp and a 16-degree parallelism, which creates 16 files like this:
dbname_env_date_01.dmp
dbname_env_date_02.dmp
.
.
.
dbname_env_date_16.dmp
What I'm trying to do is to just extract this "dbname_env_date", so I can use that parameter when importing into another env database.
What I've got so far is this:
dump_filename=$(ls -tr *.dmp | tail -1)
which gives me something like this:
dbname_env_date_16.dmp
and I want it to use later like this:
imdp ' / as sysdba ' dumpfile=$dump_filename_u%.dmp
linux scripting oracle-database
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm trying to automate a database refresh but, now I'm stuck at a part trying to extract the dump files filename to use it with the IMPDP command.
The thing is that we use this parameter doing the export:
dumpfile=dbname_env_date_%u.dmp and a 16-degree parallelism, which creates 16 files like this:
dbname_env_date_01.dmp
dbname_env_date_02.dmp
.
.
.
dbname_env_date_16.dmp
What I'm trying to do is to just extract this "dbname_env_date", so I can use that parameter when importing into another env database.
What I've got so far is this:
dump_filename=$(ls -tr *.dmp | tail -1)
which gives me something like this:
dbname_env_date_16.dmp
and I want it to use later like this:
imdp ' / as sysdba ' dumpfile=$dump_filename_u%.dmp
linux scripting oracle-database
I'm trying to automate a database refresh but, now I'm stuck at a part trying to extract the dump files filename to use it with the IMPDP command.
The thing is that we use this parameter doing the export:
dumpfile=dbname_env_date_%u.dmp and a 16-degree parallelism, which creates 16 files like this:
dbname_env_date_01.dmp
dbname_env_date_02.dmp
.
.
.
dbname_env_date_16.dmp
What I'm trying to do is to just extract this "dbname_env_date", so I can use that parameter when importing into another env database.
What I've got so far is this:
dump_filename=$(ls -tr *.dmp | tail -1)
which gives me something like this:
dbname_env_date_16.dmp
and I want it to use later like this:
imdp ' / as sysdba ' dumpfile=$dump_filename_u%.dmp
linux scripting oracle-database
linux scripting oracle-database
edited Sep 9 at 21:01
Rui F Ribeiro
36.7k1271116
36.7k1271116
asked Aug 21 at 17:29
Eduardo Santiago López
33
33
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
There is no need to use tail, you know that you get all 16 files.
dump_filename=$(ls -t *_01.dmp | head -n 1)
dump_filename=$dump_filename%_01.dmp
dump_filename="$dump_filename.dmp"
The first line will get the name of the newest file *_01.dmp
, the second line will remove the _01.dmp
from the name. The third line appends .dmp
.
You can also use this:
dump_filename=$(ls -t *_01.dmp | head -n 1 | sed -e 's/_01.dmp/.dmp/')
Hi, this actually does what I wanted, regarding the tail I use it because I want the latest dump files on the directory, sometimes no one cares to clean dump files that were already used. On the other hand, how can I do to preserve the ".dmp": to look like this "dbname_env_date.dmp". And is it possible to do it in one line piping the output or something like xargs?. Thank you very much for your help, I'm not very familiar with editing (Awk, Sed, Tr).
â Eduardo Santiago López
Aug 21 at 17:50
This will get you the newest file. Reversing the sorting and using the first line is in theory faster, because you don't need to read the whole output, but in practice the difference will not be noticeable. It is almost always possible to do it in one line, but is it worth the reduced readability?
â RalfFriedl
Aug 21 at 17:57
Well, at least for me looks a lot better all in one line, at least in this case where the line seems pretty easy to read. Thank you very much for you help, I completetly forgot that sed can do that. Thank you Sir. I appreciate you help.
â Eduardo Santiago López
Aug 21 at 18:04
If the this answered your question, you can accept the answer.
â RalfFriedl
Aug 21 at 18:11
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
There is no need to use tail, you know that you get all 16 files.
dump_filename=$(ls -t *_01.dmp | head -n 1)
dump_filename=$dump_filename%_01.dmp
dump_filename="$dump_filename.dmp"
The first line will get the name of the newest file *_01.dmp
, the second line will remove the _01.dmp
from the name. The third line appends .dmp
.
You can also use this:
dump_filename=$(ls -t *_01.dmp | head -n 1 | sed -e 's/_01.dmp/.dmp/')
Hi, this actually does what I wanted, regarding the tail I use it because I want the latest dump files on the directory, sometimes no one cares to clean dump files that were already used. On the other hand, how can I do to preserve the ".dmp": to look like this "dbname_env_date.dmp". And is it possible to do it in one line piping the output or something like xargs?. Thank you very much for your help, I'm not very familiar with editing (Awk, Sed, Tr).
â Eduardo Santiago López
Aug 21 at 17:50
This will get you the newest file. Reversing the sorting and using the first line is in theory faster, because you don't need to read the whole output, but in practice the difference will not be noticeable. It is almost always possible to do it in one line, but is it worth the reduced readability?
â RalfFriedl
Aug 21 at 17:57
Well, at least for me looks a lot better all in one line, at least in this case where the line seems pretty easy to read. Thank you very much for you help, I completetly forgot that sed can do that. Thank you Sir. I appreciate you help.
â Eduardo Santiago López
Aug 21 at 18:04
If the this answered your question, you can accept the answer.
â RalfFriedl
Aug 21 at 18:11
add a comment |Â
up vote
0
down vote
accepted
There is no need to use tail, you know that you get all 16 files.
dump_filename=$(ls -t *_01.dmp | head -n 1)
dump_filename=$dump_filename%_01.dmp
dump_filename="$dump_filename.dmp"
The first line will get the name of the newest file *_01.dmp
, the second line will remove the _01.dmp
from the name. The third line appends .dmp
.
You can also use this:
dump_filename=$(ls -t *_01.dmp | head -n 1 | sed -e 's/_01.dmp/.dmp/')
Hi, this actually does what I wanted, regarding the tail I use it because I want the latest dump files on the directory, sometimes no one cares to clean dump files that were already used. On the other hand, how can I do to preserve the ".dmp": to look like this "dbname_env_date.dmp". And is it possible to do it in one line piping the output or something like xargs?. Thank you very much for your help, I'm not very familiar with editing (Awk, Sed, Tr).
â Eduardo Santiago López
Aug 21 at 17:50
This will get you the newest file. Reversing the sorting and using the first line is in theory faster, because you don't need to read the whole output, but in practice the difference will not be noticeable. It is almost always possible to do it in one line, but is it worth the reduced readability?
â RalfFriedl
Aug 21 at 17:57
Well, at least for me looks a lot better all in one line, at least in this case where the line seems pretty easy to read. Thank you very much for you help, I completetly forgot that sed can do that. Thank you Sir. I appreciate you help.
â Eduardo Santiago López
Aug 21 at 18:04
If the this answered your question, you can accept the answer.
â RalfFriedl
Aug 21 at 18:11
add a comment |Â
up vote
0
down vote
accepted
up vote
0
down vote
accepted
There is no need to use tail, you know that you get all 16 files.
dump_filename=$(ls -t *_01.dmp | head -n 1)
dump_filename=$dump_filename%_01.dmp
dump_filename="$dump_filename.dmp"
The first line will get the name of the newest file *_01.dmp
, the second line will remove the _01.dmp
from the name. The third line appends .dmp
.
You can also use this:
dump_filename=$(ls -t *_01.dmp | head -n 1 | sed -e 's/_01.dmp/.dmp/')
There is no need to use tail, you know that you get all 16 files.
dump_filename=$(ls -t *_01.dmp | head -n 1)
dump_filename=$dump_filename%_01.dmp
dump_filename="$dump_filename.dmp"
The first line will get the name of the newest file *_01.dmp
, the second line will remove the _01.dmp
from the name. The third line appends .dmp
.
You can also use this:
dump_filename=$(ls -t *_01.dmp | head -n 1 | sed -e 's/_01.dmp/.dmp/')
edited Aug 21 at 17:59
answered Aug 21 at 17:36
RalfFriedl
3,7451624
3,7451624
Hi, this actually does what I wanted, regarding the tail I use it because I want the latest dump files on the directory, sometimes no one cares to clean dump files that were already used. On the other hand, how can I do to preserve the ".dmp": to look like this "dbname_env_date.dmp". And is it possible to do it in one line piping the output or something like xargs?. Thank you very much for your help, I'm not very familiar with editing (Awk, Sed, Tr).
â Eduardo Santiago López
Aug 21 at 17:50
This will get you the newest file. Reversing the sorting and using the first line is in theory faster, because you don't need to read the whole output, but in practice the difference will not be noticeable. It is almost always possible to do it in one line, but is it worth the reduced readability?
â RalfFriedl
Aug 21 at 17:57
Well, at least for me looks a lot better all in one line, at least in this case where the line seems pretty easy to read. Thank you very much for you help, I completetly forgot that sed can do that. Thank you Sir. I appreciate you help.
â Eduardo Santiago López
Aug 21 at 18:04
If the this answered your question, you can accept the answer.
â RalfFriedl
Aug 21 at 18:11
add a comment |Â
Hi, this actually does what I wanted, regarding the tail I use it because I want the latest dump files on the directory, sometimes no one cares to clean dump files that were already used. On the other hand, how can I do to preserve the ".dmp": to look like this "dbname_env_date.dmp". And is it possible to do it in one line piping the output or something like xargs?. Thank you very much for your help, I'm not very familiar with editing (Awk, Sed, Tr).
â Eduardo Santiago López
Aug 21 at 17:50
This will get you the newest file. Reversing the sorting and using the first line is in theory faster, because you don't need to read the whole output, but in practice the difference will not be noticeable. It is almost always possible to do it in one line, but is it worth the reduced readability?
â RalfFriedl
Aug 21 at 17:57
Well, at least for me looks a lot better all in one line, at least in this case where the line seems pretty easy to read. Thank you very much for you help, I completetly forgot that sed can do that. Thank you Sir. I appreciate you help.
â Eduardo Santiago López
Aug 21 at 18:04
If the this answered your question, you can accept the answer.
â RalfFriedl
Aug 21 at 18:11
Hi, this actually does what I wanted, regarding the tail I use it because I want the latest dump files on the directory, sometimes no one cares to clean dump files that were already used. On the other hand, how can I do to preserve the ".dmp": to look like this "dbname_env_date.dmp". And is it possible to do it in one line piping the output or something like xargs?. Thank you very much for your help, I'm not very familiar with editing (Awk, Sed, Tr).
â Eduardo Santiago López
Aug 21 at 17:50
Hi, this actually does what I wanted, regarding the tail I use it because I want the latest dump files on the directory, sometimes no one cares to clean dump files that were already used. On the other hand, how can I do to preserve the ".dmp": to look like this "dbname_env_date.dmp". And is it possible to do it in one line piping the output or something like xargs?. Thank you very much for your help, I'm not very familiar with editing (Awk, Sed, Tr).
â Eduardo Santiago López
Aug 21 at 17:50
This will get you the newest file. Reversing the sorting and using the first line is in theory faster, because you don't need to read the whole output, but in practice the difference will not be noticeable. It is almost always possible to do it in one line, but is it worth the reduced readability?
â RalfFriedl
Aug 21 at 17:57
This will get you the newest file. Reversing the sorting and using the first line is in theory faster, because you don't need to read the whole output, but in practice the difference will not be noticeable. It is almost always possible to do it in one line, but is it worth the reduced readability?
â RalfFriedl
Aug 21 at 17:57
Well, at least for me looks a lot better all in one line, at least in this case where the line seems pretty easy to read. Thank you very much for you help, I completetly forgot that sed can do that. Thank you Sir. I appreciate you help.
â Eduardo Santiago López
Aug 21 at 18:04
Well, at least for me looks a lot better all in one line, at least in this case where the line seems pretty easy to read. Thank you very much for you help, I completetly forgot that sed can do that. Thank you Sir. I appreciate you help.
â Eduardo Santiago López
Aug 21 at 18:04
If the this answered your question, you can accept the answer.
â RalfFriedl
Aug 21 at 18:11
If the this answered your question, you can accept the answer.
â RalfFriedl
Aug 21 at 18:11
add a comment |Â
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f463927%2fextract-dump-files-files-names%23new-answer', 'question_page');
);
Post as a guest
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
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
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