Required to get a portion of a text

Hello Gurus,
I have a filesystem like below :

/u03/oracle/EBSDEV/fs1/EBSapps/appl

I want to get only the portion of the above text like below...

/u03/oracle/EBSDEV

Can you please advice on this?

Thanks-
P

How would you identify the partial string to extract?

  • three levels deep?
  • three levels chopped off from the end?
  • contains "EBSDEV"?
  • "fs1" and rest of line chopped off?
    Where and how is that string stored, in a file, a (shell) variable, output of a command?

you could try this:

find / -maxdepth 3 -name EBSDEV

Thank you for your advice. But the above code is giving such below details:

/u03/oracle/EBSDEV 
/u08/oracle/EBSDEV 
/u08nfs/oracle/EBSDEV

My requirement is only to get the "/u03/oracle/EBSDEV".

How to achieve this? Please advice.

Thanks-
P

---------- Post updated at 06:54 PM ---------- Previous update was at 06:48 PM ----------

Hello RudiC,

The below is the details:

Ans: Yes.. It should be 3 level deep.

Ans: No, the output should be /u03/oracle/EBSDEV

Ans: Yes.. It will contain EBSDEV

Ans: Yes, - "fs1" and rest of line will be chopped off

Ans: The output of a command will be stored at a variable.

Thanks-
P

find /u03/oracle -maxdepth 1 -mindepth 1 -type d -name EBSDEV
$path="/u03/oracle/EBSDEV/fs1/EBSapps/appl"
echo ${path%/*/*/*}