Finding Last Occurance Of a Char

Hi,

I need to fine out the Last occurance of / in the following out out.

crontab -l | grep RMAN_VTL_Bkup.sh | tail -1 | awk '{print $6}'
/oracle/PI1/software/RMAN/backup/RMAN_VTL_Bkup.sh

Coudl you please let me know

Thanking you inadvance,

Something like this?

crontab -l | awk -F"/" '/RMAN_VTL_Bkup.sh/{s=$NF}END{print s}' 

From the following string I need to Find the last occurance of /. the last occurance is after the backup word. i want to know the posisiting of /.

/oracle/PI1/software/RMAN/backup/RMAN_VTL_Bkup.sh

Give an example of the output of crontab -l and the desired output.

Could this help you?

var='/oracle/PI1/software/RMAN/backup/RMAN_VTL_Bkup.sh'
echo $(($(expr length $(echo ${var%/*}))+1))

This is the entry in the cron. I am trying to implement one script for which we need
some Input from .env file. env file contain some variable those could be usefull in my scirpy.like ORACLE_HOME,SID,BACKUP_TYP..etc

45 02 24 02 4 /oracle/PQR1/oracle/Rman/backup/RMAN_VTL_Bkup.sh tapebackup_PI1_Arch.env

This is really unclear, please redefine your question.

I have a string,

/oracle/PQR1/oracle/Rman/backup/RMAN_VTL_Bkup.sh

Through scripting i need to find out the last occurance of the "/" In the givien text.

Did pravin27's solution does not work out for you..? Anyway try..

echo 'oracle/PQR1/oracle/Rman/backup/RMAN_VTL_Bkup.sh tapebackup_PI1_Arch.env'|sed 's/[^/]*$//'|wc -c
1 Like