Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tlug] Seeing Arguments (was Re: fun with filenames with embedded blanks)



On Tue, 4 Aug 2009 14:37:28 -0400, I wrote:

> Dave M G wrote:
> 
> > And have I incorporated the find syntax correctly? 
> 
> Learn how to explore that question yourself. 
> Put an echo in front of the ultimate 
> command to see what would be executed, but without executing it. 

For example: 

>    echo uniconverter input ${i} output ${i%.ai}.svg

By the way, when you look at the output of echo, 
you will not know where one argument ended and another began. 
When I am worried about such, I slap together some quick hack 
like below: 

   [jep200404@example.com util]$ cat showargs.c
   #include <stdlib.h>
   #include <stdio.h>
   
   int main(int argc,char *argv[])
   {
      int i;
   
      for (i=0;i<argc;i++)
         printf("argv[%d]=\"%s\"\n",i,argv[i]);
   
      return EXIT_SUCCESS;
   }
   
   [jep200404@example.com util]$ make showargs
   cc     showargs.c   -o showargs
   [jep200404@example.com util]$ echo hello world "Hello world" "^AHello^Bworld^E"
   hello world Hello world Helloworld
   [jep200404@example.com util]$ ./showargs hello world "Hello world" "^AHello^Bworld^E"
   argv[0]="./showargs"
   argv[1]="hello"
   argv[2]="world"
   argv[3]="Hello world"
   argv[4]="Helloworld"
   [jep200404@example.com util]$ ./showargs hello world "Hello world" "^AHello^Bworld^E" | cat -A
   argv[0]="./showargs"$
   argv[1]="hello"$
   argv[2]="world"$
   argv[3]="Hello world"$
   argv[4]="^AHello^Bworld^E"$
   [jep200404@example.com util]$ 

Experiment! Explore! 



Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links