![]() |
|
|
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 |
| How to print largest and smallest number. | amp10388 | UNIX for Dummies Questions & Answers | 2 | 05-07-2008 11:28 AM |
| print or display certain number of file | jerardfjay | Shell Programming and Scripting | 2 | 04-05-2008 12:12 PM |
| grouping of objects and print their number | cdfd123 | Shell Programming and Scripting | 3 | 10-04-2007 02:49 AM |
| to print number one less than actual number | cdfd123 | Shell Programming and Scripting | 4 | 09-06-2007 07:56 AM |
| How to print number of lines with awk ? | maheshsri | Shell Programming and Scripting | 1 | 11-18-2005 02:19 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Hi,
I am using for loop as follow: for n in `ls` do echo "$n" done The code is running fine and aI am getting valid output as: jick zenny assi yogi But 1also want to print count in front of each output like this: 1 jick 2 zenny 3 assi 4 yogi What should I add in my logic for achiving this? Kinly advise. Regards, Yogi |
|
||||
|
Thanks thats working for me...
But my concerns was not about to put list number in front of ls but my concern is how to print a count that for which instance a loop is going to execute: suppose i have file "yogi.txt" and i write down a code as for n in yogi.txt do echo "$n" done Output is: yogi is not a good progrmmer but what should i do if i want my output to be as follow: 1.) yogi 2.) is 3.) not a 4.) good 5.) programmer |
|
||||
|
Thanks for the help.
I know this was the silliest question I have ever asked, but the solution was not striking since last 1 hour. Now I got the solution. My code should be: for n in yogi.txt do b=`expr $b + 1` echo "$b.) $n" done |
|
||||
|
Thanks for the help.
I know this was the silliest question I have ever asked, but the solution was not striking since last 1 hour. Now I got the solution. My code should be: for n in yogi.txt do b=`expr $b + 1` echo "$b.) $n" done |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|