RE: Shell scripting: Absolute path name of a file given as parameter

2007-04-13 Thread Aitor San Juan
Thanks a lot to all who replied.

Aitor.

-Mensaje original-
De: Pete Slagle [mailto:[EMAIL PROTECTED]
Enviado el: jueves, 12 de abril de 2007 19:04
Para: [EMAIL PROTECTED]
Asunto: Re: Shell scripting: Absolute path name of a file given as
parameter


Aitor San Juan wrote:

 I have developed a shell script that, among other things, shows the filename
 that was specified as a parameter.
 
 However, when I invoke the script and the file is located in the current 
 working
 directory, it just shows: ./my_input_filename
 
 I'd like the script to show the full path name of the input file. I wonder
 whether there is or not an equivalent to %~f1 (Windows Batch file 
 programming).
 This parameter extension expands parameter %1 ($1 in shell scripting jargon) 
 to a
 Fully qualified path name.

man (1) realpath

For example:

 #!/bin/sh
 echo The full path of the file name is $(realpath $1)


 LEGEZKO OHARRA / AVISO LEGAL / LEGAL ADVICE * 
Mezu honek isilpeko informazioa gorde dezake, edo jabea duena, edota legez 
babestuta dagoena. Zuri zuzendua ez bada, bidali duenari esan eta ezabatu, 
inori berbidali edo gorde gabe, legeak debekatzen duelako mezuak erabiltzea 
baimenik gabe. 
--
Este mensaje puede contener información confidencial, en propiedad o legalmente 
protegida. Si usted no es el destinatario, le rogamos lo comunique al remitente 
y proceda a borrarlo, sin reenviarlo ni conservarlo, ya que su uso no 
autorizado está prohibido legalmente.
--
This message may contain confidential, proprietary or legally privileged 
information. If you are not the intended recipient of this message, please 
notify it to the sender and delete without resending or backing it, as it is 
legally prohibited.
**
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Shell scripting: Absolute path name of a file given as parameter

2007-04-12 Thread Aitor San Juan
Hi List,

Just a simple question.

I have developed a shell script that, among other things, shows the filename
that was specified as a parameter.

However, when I invoke the script and the file is located in the current working
directory, it just shows: ./my_input_filename

I'd like the script to show the full path name of the input file. I wonder
whether there is or not an equivalent to %~f1 (Windows Batch file programming).
This parameter extension expands parameter %1 ($1 in shell scripting jargon) to 
a
Fully qualified path name.

Any hint would be highly appreciated.

Thanks in advance.

Aitor.


 LEGEZKO OHARRA / AVISO LEGAL / LEGAL ADVICE * 
Mezu honek isilpeko informazioa gorde dezake, edo jabea duena, edota legez 
babestuta dagoena. Zuri zuzendua ez bada, bidali duenari esan eta ezabatu, 
inori berbidali edo gorde gabe, legeak debekatzen duelako mezuak erabiltzea 
baimenik gabe. 
--
Este mensaje puede contener información confidencial, en propiedad o legalmente 
protegida. Si usted no es el destinatario, le rogamos lo comunique al remitente 
y proceda a borrarlo, sin reenviarlo ni conservarlo, ya que su uso no 
autorizado está prohibido legalmente.
--
This message may contain confidential, proprietary or legally privileged 
information. If you are not the intended recipient of this message, please 
notify it to the sender and delete without resending or backing it, as it is 
legally prohibited.
**
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Shell scripting: Absolute path name of a file given as parameter

2007-04-12 Thread Garrett Cooper

Aitor San Juan wrote:

Hi List,

Just a simple question.

I have developed a shell script that, among other things, shows the filename
that was specified as a parameter.

However, when I invoke the script and the file is located in the current working
directory, it just shows: ./my_input_filename

I'd like the script to show the full path name of the input file. I wonder
whether there is or not an equivalent to %~f1 (Windows Batch file programming).
This parameter extension expands parameter %1 ($1 in shell scripting jargon) to 
a
Fully qualified path name.

Any hint would be highly appreciated.

Thanks in advance.

Aitor.
You could always do it relative to the current working path, i.e. 
`pwd`/./my_input_filename.


There's another way to do this by determining the absolute path of the 
shell script, but that was a bit more complicated and I don't remember 
where the documentation for that is right now..

-Garrett
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Shell scripting: Absolute path name of a file given as parameter

2007-04-12 Thread Pete Slagle
Aitor San Juan wrote:

 I have developed a shell script that, among other things, shows the filename
 that was specified as a parameter.
 
 However, when I invoke the script and the file is located in the current 
 working
 directory, it just shows: ./my_input_filename
 
 I'd like the script to show the full path name of the input file. I wonder
 whether there is or not an equivalent to %~f1 (Windows Batch file 
 programming).
 This parameter extension expands parameter %1 ($1 in shell scripting jargon) 
 to a
 Fully qualified path name.

man (1) realpath

For example:

 #!/bin/sh
 echo The full path of the file name is $(realpath $1)


___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]