Link to home
Start Free TrialLog in
Avatar of tommym121
tommym121Flag for Canada

asked on

How to extract a string that have a given substring within in a line in a shell script

I have multiple lines like the following line
'/home/user1/myapp -s -t -f /tmp/abc.cfg
I need to extract /tmp/abc.cfg out. It always prefix with this token '-f;'. The extracted string has to have ".cfg".

what kind of unix tool can I use.  I have no access to GNU tools
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

I fear I don't really understand what you're after.
What exactly is the expected output?
Is the shown input line complete or does/can it contain more text?
Do you really want to search for "/tmp/abc.cfg" or rather for any string that might follow "-f"?
ASKER CERTIFIED SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tommym121

ASKER

Thanks
You're welcome ;)