|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Greetings, In my script I have to process variables whose values (happen to be file names) contains the '%' character Since I have no control over how files are named, I was wondering if there is a way I can get around the situation which I am emulating through an example below: # export filename=Hello%20World # printf $filename bash: printf: `W': invalid format character Thanks, Farid |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Farid Hamjavar wrote:
> Greetings, > > In my script I have to process variables whose values > (happen to be file names) contains the '%' character > > Since I have no control over how files are named, > I was wondering if there is a way I can get around > the situation which I am emulating through an example below: > > > > # export filename=Hello%20World > > # printf $filename > bash: printf: `W': invalid format character Provide a format string for printf... $ filename="Hello%20World" $ printf "%s\n" "$filename"' Hello%20World Janis > > > > > Thanks, > Farid > > > |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On 11/12/2007 5:16 PM, Farid Hamjavar wrote: > Greetings, > > In my script I have to process variables whose values > (happen to be file names) contains the '%' character > > Since I have no control over how files are named, > I was wondering if there is a way I can get around > the situation which I am emulating through an example below: > > > > # export filename=Hello%20World > > # printf $filename > bash: printf: `W': invalid format character Yes, use printf as the manual page tells you, i.e.: printf <format> <text> so in this case you'd do: printf "%s\n" "$filename" Regards, Ed. |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
In news:Pine.LNX.4.64.0711121611080.17704@chishio.swc p.com,
Farid Hamjavar <hamjavar@unm.edu> wrote: > In my script I have to process variables whose values > (happen to be file names) contains the '%' character > > Since I have no control over how files are named, > I was wondering if there is a way I can get around > the situation which I am emulating through an example below: > > # export filename=Hello%20World > # printf $filename > bash: printf: `W': invalid format character Format the output as a string: printf %s $filename |
|
![]() |
| Outils de la discussion | |
|
|