![]() |
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 |
| perl + array and incrementing number | Optimus_P | Shell Programming and Scripting | 5 | 07-18-2008 02:55 AM |
| Port incrementing using one file | coolkid | Shell Programming and Scripting | 0 | 06-05-2008 01:42 PM |
| Port num incrementing | coolkid | Shell Programming and Scripting | 5 | 05-28-2008 05:51 PM |
| shell script help: sorting, incrementing environment variables and stuff | secoif | Shell Programming and Scripting | 1 | 05-08-2008 07:04 AM |
| New iteration of for-loop without incrementing? | jeriryan87 | Shell Programming and Scripting | 0 | 07-02-2007 02:13 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
incrementing a for loop
I have,
LIST="a b c d e" for word in $LIST do echo $word done would give me a b c d e With the first iteration of the for loop, I get "a" as the result. Is it possible that I get both "a" and "b" in only the first iteration. In the next iteration I get "c" and "d" and so on. I hope I am clear enough!! Thanks |
|
||||
|
Quote:
# echo $LIST | awk '{ for (i=1;i<=NF;i++) { printf $i" "; if (i%2==0) { printf "\n"} } }END { printf "\n" }' a b c d e # HTH. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|