Extract Dump Files Files Names

The name of the pictureThe name of the pictureThe name of the pictureClash 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









share|improve this question



























    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









    share|improve this question

























      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









      share|improve this question















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      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




















          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/')





          share|improve this answer






















          • 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










          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          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',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          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






























          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/')





          share|improve this answer






















          • 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














          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/')





          share|improve this answer






















          • 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












          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/')





          share|improve this answer














          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/')






          share|improve this answer














          share|improve this answer



          share|improve this answer








          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
















          • 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

















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          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













































































          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Displaying single band from multi-band raster using QGIS

          How many registers does an x86_64 CPU actually have?