kron Scripting

aruku
aruku used Ask the Experts™
on
Hi  I need to check if a file exists or not in a directory and then I have a file in one directory as sample. I need to move it to other directory with name sample_3355. The last data of sample.

Then I will execute the script and pu

sample
12345
23
3355

please help
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2007

Commented:
Something like
#!/bin/ksh
cd /path/to/dir

if [ -f sample ]
then
   newdir=sample_$(tail -1 sample)
   mkdir $newdir
   mv sample $newdir
fi

Open in new window

Author

Commented:
can you please help me as if

the file is in /apps/dataapps/ghgjj
and it need to transfer to /apps/ffgjr/fhdjd
Top Expert 2007
Commented:
Try
#!/bin/ksh
cd /apps/dataapps/ghgjj

if [ -f sample ]
then
   newdir=sample_$(tail -1 sample)
   mkdir /apps/ffgjr/fhdjd/$newdir
   mv sample /apps/ffgjr/fhdjd/$newdir
fi

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial