How to display a filename and its directory using a ...?

How to display a filename and its directory using a ...?

Post by Lee Hon Chor (cf » Tue, 21 Nov 2000 04:00:00



Hi,

I wanna write a Bourne shell script that can display a file's
name and its location, i.e. its directory path.  The outline of the
shell script, named getfilename,  is like

################################
#!/bin/sh
#program name=getfilename

for file in $*
do

 [statements that can help display the file's name and its
  directory path]

done
################################

so that when I apply the script to a file as

Quote:>getfilename file1

it gives me

Quote:>pathname/file1

Hope that I have made the requirements clear and easy to understand.
Thanks in advance.

David

 
 
 

How to display a filename and its directory using a ...?

Post by Glenn Wes » Tue, 21 Nov 2000 04:00:00




Quote:> Hi,

> I wanna write a Bourne shell script that can display a file's
> name and its location, i.e. its directory path.  The outline of the
> shell script, named getfilename,  is like

> ################################
> #!/bin/sh
> #program name=getfilename

> for file in $*
> do

>  [statements that can help display the file's name and its
>   directory path]

> done
> ################################

> so that when I apply the script to a file as

> >getfilename file1

> it gives me

> >pathname/file1

> Hope that I have made the requirements clear and easy to understand.
> Thanks in advance.

No, the requirements aren't totally clear.  Do you want the script to
find the given file and display the location and file name?  In that
case, why not just use the "find" command?

HTH...

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

How to display a filename and its directory using a ...?

Post by Barry Margoli » Wed, 22 Nov 2000 09:22:18




Quote:>Hi,

>I wanna write a Bourne shell script that can display a file's
>name and its location, i.e. its directory path.  The outline of the
>shell script, named getfilename,  is like

>################################
>#!/bin/sh
>#program name=getfilename

>for file in $*
>do

> [statements that can help display the file's name and its
>  directory path]

>done
>################################

>so that when I apply the script to a file as

>>getfilename file1

>it gives me

>>pathname/file1

>Hope that I have made the requirements clear and easy to understand.
>Thanks in advance.

If the filename doesn't have an explicit pathname, the pathname is whatever
your current directory is.  I suspect you're looking for something other
than this, so you'll have to rephrase your question.

--

Genuity, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.

 
 
 

How to display a filename and its directory using a ...?

Post by ratheesh r pa » Wed, 22 Nov 2000 12:41:32


Hi

Quote:>I wanna write a Bourne shell script that can display a file's
>name and its location, i.e. its directory path.
>......

> >>getfilename file1

> >it gives me

> >>pathname/file1

The following code may satisfy your requirements.

for filename in $*
do
 echo "`pwd`/$filename"
done

Bye