So let's say that my script is called item.sh, and if I call it like "./item.sh 3 5", it should simply print me the items in my directory, but starting from the third item, and printing until the fifth one. So it should print third, fourth and fifth items only. Let's say that I have this as the output of my unedited script:
item:Desktop item:Development item:Documents item:Downloads item:Dropbox item:Eclipse item:examples.desktop item:git item:grub.txt item:hw.c~ item:hw.sh item:loops.sh item:Music item:Pictures item:Progex-Cloud item:Public item:public_html item:rvm.sh item:Softwares item:Templates item:trunk item:Ubuntu item:One item:Videos
Then after editing my script and executing it like: "./item.sh 3 5", I want the output to be:
item:Documents item:Downloads item:Dropbox
For my initial program, I have the following script, which works just fine:
#!/bin/bash
for i in $( ls );
do
echo item:$i
done
But when it comes to adding two parameters to my original script and achieving the needed output, I'm having difficulties. I have tried many things, but simply it doesn't work. Seems like I cannot find a proper algorihtm. If someone could give me just one working version, I would be glad. Lastly, I have something like this, which doesn't work as needed of course, and uses just one parameter.
#!/bin/bash COUNTER=$1 for COUNTER in $( ls ); do echo item:$COUNTER done
This post has been edited by erkant: 24 October 2012 - 06:55 AM

New Topic/Question
Reply



MultiQuote




|