Search code examples
shellechoksh

Shell : ksh script with echo command not showing anything


As my title implies it I guess, I'm a beginner at shell and I've got a issue I couldn't resolve.

I'm typing my script in Notepad++ and was careful with removing the CR. I execute my script in PuttY and it doesn't show anything even though it has an echo command in it. I guess the error is iun my script but I don't know where as PuttY doesn't show me any error.

The script :

for ((i=wc -l <ListeTableFicToLoadRetour.lst; i>=0; i-=1)) 
do 
  echo ${i} 
done

The wc command works alone, it shows that there are 2 lines in the file which is correct.

When I enter the script in PuttY : devfic@psd949(DEV/DEV):/projets/dstage/d_fic/home/devfic/sh>test.ksh devfic@psd949(DEV/DEV):/projets/dstage/d_fic/home/devfic/sh>

I'm sorry if it's a fool's mistake, i just started ksh a few days ago :/


Solution

  • wc -l <ListeTableFicToLoadRetour.lst needs to be executed:

    for ((i=$(wc -l <ListeTableFicToLoadRetour.lst); i>=0; i-=1)) 
    do 
      echo ${i} 
    done