![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Passwd Changing Acting Strange | rockusa | SUN Solaris | 2 | 12-10-2007 05:41 PM |
| HP-UX weird FTP ? | IngmarMeins | HP-UX | 10 | 11-29-2005 05:22 PM |
| weird core | nkshirsagar | HP-UX | 1 | 10-05-2005 11:33 PM |
| weird stuff | woofie | Windows & DOS: Issues & Discussions | 4 | 11-16-2004 04:41 PM |
| Weird SSH issue | AKM | UNIX for Advanced & Expert Users | 6 | 11-08-2004 11:13 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Why for loop is acting weird
Hey i have a small script in which i check if a file with that pattern exists or not. If present then i go ahead with further processing.
In the present situation i have only one file with that name and for loop is reading twice. Here is the script. And the output of debug mode. Please help. Quote:
I pass 2 parameters to the script. and the debug output shows it;s reading 2 times in the for loop. Quote:
|
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Notice the whitespace in
fullpattern=AUD01_CARE_DLY_20060912 .dat You need to get rid of that space or alternatively use Code:
for file in "$fullpattern" ; do [ "$file" != "$fullpattern" ] && filecount=$filecount+1 done |
|
#3
|
|||
|
|||
|
AUD01_CARE_DLY_20060912[SPACE].dat
So in for loop it will take as two arguments. If you want to treat as single argument then do this Code:
for file in "$fullpattern" ; do |
|
#4
|
|||
|
|||
|
Thanks friends,
I got it working but i don't understand how the spaces are coming as my code doesn't have any spaces in it. Quote:
|
|
#5
|
|||
|
|||
|
check this variable NEW_DT contains any space. if you have still problem show us how did you get the value for that variable
|
|
#6
|
|||
|
|||
|
Thanks Anbu, the NEW_DT is having space in it. It solved the problem.
Thanks, |
|||
| Google The UNIX and Linux Forums |