Help w\ Bash Script

Hi everyone. I am a Linux scripting newbie and and was hoping to get some assistance with a bash script I am working on. I am attempting to write a bash script to determine if a user specified file is in the current PATH environment variable. If the file is present in the path, I need to then display the filename with the the leading directory specification removed, filesize in bytes, and file permission on octal. The script would be ececuted by the syntax of: command filename . I was thinking I might be able to include the find command, for example, find -name $1 -print or something similar. Any help to get me headed in the right direction would be greatly appreciated.

Thanks.

Almost sounds like a homework question and if so, you might want to read this ... Simple rules of the UNIX.COM forums.

Otherwise, post what of your script you've completed so we can assist you more.

Thanks Cameron.

basename $(which $1) works as far as searching PATH for a user specified file. And, ls -l | awk '{print $5}' will give me a filesize in bytes and echo "2i8o`ls -ld file_name|cut -c4,7,10|tr xsST- 01110``ls -ld file_name|cut -c2-10|tr rwsxtST- 11111000-`p"|dc will give me the file permissions in octal, but I was a little confused on how I could get this info in a single tab separated list?

Oops, my bad. The construct for ANSI C escapes is $'', and it doesn't allow parameters to be embedded. Something like $'\t' to separate your fields, I guess. Stuff the output of each of those other 3 into shell parameters, and then stick them together:

NAME=`basename $(which $1)`
SIZE=...
PERMS=...

echo $NAME$'\t'$SIZE$'\t'$PERMS

This what you were looking for?