0

This question already has an answer here:

I want to include * as mentioned below in double inverted commas, but i am not able to find the file. When i remove the inverted double inverted commas it works.

$CONTROL=/bkp/Test/back/13_Mar_2018/
ls -lrt "$CONTROL\*controlfile";

marked as duplicate by Sparhawk, Archemar, Jeff Schaller, Anthony Geoghegan, Kiwy Mar 15 '18 at 15:19

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    What have you tried to do so far, what do want to happen, and where are you getting stuck? – Nasir Riley Mar 15 '18 at 3:22
  • I am trying to create a script where – James Mar 15 '18 at 3:28
  • I am trying to create a script which should call the controlfile as the file contains "Test13032018_970629552_kfstl8dg_1_1_" should be excluded and search only for controlfile [oracle@ ~]$ ls -lrt "/home/oracle/bkp/Test/back/13_Mar_2018/Test13032018_970629552_kfstl8dg_1_1_controlfile" -rw-r----- 1 oracle bseerp 2375680 Mar 15 08:56 /home/oracle/bkp/Test/back/13_Mar_2018/Test13032018_970629552_kfstl8dg_1_1_controlfile [oracle@ ~]$ ls -lrt "/home/oracle/bkp/Test/back/13_Mar_2018/*controlfile" ls: cannot access /home/oracle/bkp/Test/back/13_Mar_2018/*controlfile: No such file or directory – James Mar 15 '18 at 3:32
0

Pathname expansion doesn't work within quotes. However, you can do something like this:

CONTROL=/bkp/Test/back/13_Mar_2018/
ls -lrt "$CONTROL"*controlfile
  • $CONTROL is quoted to prevent side effects like field splitting.
  • * is not quoted to allow pathname expansion.
  • controlfile doesn't need to be quoted, but you can quote it if you want.
  • I am unable to call it, as mentioned below. Please help. export $CONTROL='/bkp01/oracle/PRODERP/backupset/2018_Mar_13/' ls -lrt $CONTROL*controlfile; – James Mar 15 '18 at 4:52
  • @James What do you exactly mean by "call it"? Do you want to run the controlfile as if it were a command/script? If yes, how many controlfiles do you have? If there are two or more, do you want to run each of them or just a specific one? By the way, feel free to unmark my answer as accepted and change the title of the question or ask a new one; it seems that the * was not the part we should focus on. – nxnev Mar 15 '18 at 6:08
  • I want the below mentioned commands to be written in a script where 'Test13032018_970629552_kfstl8dg_1_1_' will keep changing. Hence, i am planning to insert * infront of controlfile,so that it executes the restore controlfile command. I have only control file which is taken as a backup rman TARGET $USER/$PASS <<EOF run { startup nomount; restore controlfile from '/home/oracle/bkp/Test/back/13_Mar_2018/Test13032018_970629552_kfstl8dg_1_1_controlfile'; sql "alter database mount"; restore database; recover database; } exit; EOF – James Mar 15 '18 at 6:14
  • @James Please add further information to the text of your question. The question does not mention executing anything other than an assignment and ls. – Kusalananda Mar 15 '18 at 6:38
  • I have been trying to create a script which will be used for automation where the rman commands in oracle is unable to find the controlfile,as the control file location must be specified in inverted commas. The text before controlfile keeps changing whenever backup happens, so i want only control file should be picked from the particular path instead of mentioning the entire texts before control file. If my restore commands finds my controlfile then my script will start working, otherwise i have to manually change the path and file name before running the script. – James Mar 15 '18 at 6:54

Not the answer you're looking for? Browse other questions tagged or ask your own question.