Shell Script

Hi,
I'm new to Scripting. Please help me.
I want to open a text file and get the date from that text file.

Thanks
David

sorry i cound not understand your requirement..

  1. you open a text file by useing "vi" editor
  2. cat or some other commands...
    could you give example that would be easy for us to give solution

Hi Dave,,

There are lots of ways one is

for text_file in yourtextfilename
do
then you can use SED or grep to find
done ..

Thanks,
Arun Kumar

Hi Srikanth & Arun,

Thanks for your reply.

I have a file named pinstat. I have to delete the contents of this file with response to date & time, Once in 2 months.

I know how to run once in 2 months using crontab commands.

But now i donno shell script. How to open that pinstat file and grep the date from it using shell scripting. And i want to delete the file contents depending on date (Eg: once in 2 months).

Thanks
David

Hi Dave ....

In this case it will go much more simpler ...

grep -v "date" filename >> tempfile
mv tempfile filename

This will do ... please let me know if you have questions......

Note : we are greping for the text that doesn't contains the date in the file and storing it in temp file and renaming the temp file to the org file .. For checking the date dynamically you can make use date command in unix . If you are not familier let me know.

Thanks,
Arun Kumar.

Hi Arun,

Thanks for your reply.

I'm not aware, how to get date dynamically from the text file which i have and how to use it in our script?

Thanks
David