Shell script passing variables

I have a procedure that creates two files only one of theses files is created at a time depending on if there was an error or not, what I need to do is to search a specified directory and pickup the name of the file that is in there and then be able to store this a a variable so that the script can then just pass in the variable to see which script to run next.

I have tried something like this

#!/bin/bash

for file in 'ls /u1/dev/procedures/sales/*.sh'; do
echo $file
done

###########

but all i get returned is

'ls /u1/dev/procedures/sales/<filename>.sh'

All I need returned is just the filename.
 

Do a man on

basename
dirname
 

You don't need 'ls' or quotes. Try:
for file in /u1/dev/procedures/sales/*.sh
do
echo $file
done

See Also
Unix Administrator Career Path

Have a Unix Problem
Do you have a UNIX Question?

Unix Books :-
UNIX Programming, Certification, System Administration, Performance Tuning Reference Books

Return to : - Unix System Administration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.
The site www.gotothings.com is in no way affiliated with or endorsed by any company listed at this site.
Any unauthorised copying or mirroring is prohibited.