Avatar of Member_2_1102506
Member_2_1102506 asked on

Bourne shell to move a file containing certain text

Hi!
I need to write a bourne shell file (to be executed by an application). I am very rusty on Bourne shell and don't know how to start what I want to do.
I need to pass the bourne shell a couple of text strings (so that they becomes $1 and $2 in the shell). I then want the shell program to cd to a specific directory and look for the files in there to find the one that has the text in $1. (If everything is working properly, there will be only one file in there with that string in it.) Having found the file , I then need to move that file to a different directory and rename it to the name in $2 (thereby removing it from the original directory.

Can you give me a start on how to do this?

Thanks in advance
Shell ScriptingRegular Expressions

Avatar of undefined
Last Comment
Member_2_1102506

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
ozo

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
Member_2_1102506

Thanks for the quick reply!
That looks promising! I'll test it out and let you know how I get on.
ASKER
Member_2_1102506

Yes it does work!

I had a feeling it might be straightforward, and when you showed me the method, it made sense. But it would have taken me a long time to work out!

Thanks
ASKER
Member_2_1102506

(See last comment by me added to question)
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck