![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| counting the packets | damn_bkb | IP Networking | 2 | 11-17-2006 07:55 AM |
| Counting and sort | bobo | UNIX for Dummies Questions & Answers | 4 | 05-23-2006 08:02 PM |
| counting characters | plelie2 | Shell Programming and Scripting | 6 | 02-25-2003 01:38 PM |
| Counting LOC in C | amatsaka | High Level Programming | 1 | 06-04-2002 03:18 PM |
| Counting time | black69star | Shell Programming and Scripting | 2 | 12-11-2001 11:42 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Counting up a variable
Hello,
I am trying to write a shell script, but i encountered a problem I cant solve alone so I hope you guys can help me. The situation is: I have a script file and a config file, in my config file I set some Variables: for example: destination=(xp, xq, xt) username=testor password=testian file1=html/de/sa_logs.php file2=html/fr/frappi the amount of files can go between 1 and xy. Now the part of the scriptfile i have problems with: i=1 b=1 while [ $i -le ${#destination[*]} ] do echo i ist $iWhat i need to do is combine file and $b so that the scrip still knows i am talking about the file1, file2,file3,filexy variables and not just some text. No Idea how I can do that. Sorry for my english it isnt my native language. Hope you can help |
|
||||
|
You can use arrays in a loop to get the filenames, it's even better to put the filenames in a file.
To loop through an array you can do something like this: Code:
file[1]=html/de/sa_logs.php
file[2]=html/fr/frappi
sourcepath="/home/"
for name in ${file[@]}
do
path="$sourcepath""$name"
echo $path
done
Code:
sourcepath="/home/" while read name do path="$sourcepath""$name" echo $path done < filenames Regards |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|