Dear Experts,
I have some directory structure something like follows. I would like to cut portion of it. Would you please help me? I have to run this on several sql's. The directory path is dynamic. I have cut what comes after first "sql" string.
Input:
/opt/fedex/acqulev1/abinitio/acqu/private_sand/legacy_acquisition/sql/DELETE/FCIS/delete_CS53_2.sql
Output:
/DELETE/FCIS/delete_CS53_2.sql
I have to do reverse of below sed.
sed 's/sql.*//'
RudiC
March 4, 2018, 3:20am
2
How / where is that string stored, in a variable? A file? A DB table?
srikanth38:
Dear Experts,
I have some directory structure something like follows. I would like to cut portion of it. Would you please help me? I have to run this on several sql's. The directory path is dynamic. I have cut what comes after first "sql" string.
Input:
/opt/fedex/acqulev1/abinitio/acqu/private_sand/legacy_acquisition/sql/DELETE/FCIS/delete_CS53_2.sql
Output:
/DELETE/FCIS/delete_CS53_2.sql
I have to do reverse of below sed.
sed 's/sql.*//'
I have got the answer, just used different delimiter.
echo /opt/fedex/acqulev1/abinitio/acqu/private_sand/legacy_acquisition/sql/DELETE/FCIS/delete_CS53_2.sql|sed 's|'$AI_SQL'||'
Aia
March 8, 2018, 1:14am
4
Consider the following, done without any external program:
fullpath='/opt/fedex/acqulev1/abinitio/acqu/private_sand/legacy_acquisition/sql/DELETE/FCIS/delete_CS53_2.sql'
pivot="sql"
remove=${fullpath#*$pivot}
echo ${fullpath%$remove}
Output:
/opt/fedex/acqulev1/abinitio/acqu/private_sand/legacy_acquisition/sql