|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | 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. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
Loop
Hi I wrote shell script to do the flowing count from 5 and down but doesn’t work please see my program Code:
#Bash x=0 y=10 while (( x < y )) do (( x = x + 1 )) grep -A $x 5 numbers >>file4.txt done these the output Code:
5 6 5 6 7 5 6 7 8 5 6 7 8 9 5 6 7 8 9 10 5 6 7 8 9 10 5 6 7 8 9 10
Last edited by vgersh99; 01-05-2013 at 02:57 PM.. Reason: code tags, please! |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
Your requirement is not so clear. Can you provide desired output? BTW If your requirement is to generate sequence of numbers ranging from 0 - 10 in BASH. Then you can simply use a for loop Code:
#!/bin/bash
for x in {0..10}
do
echo $x
done |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
loop
I would like to have the output like this
5 6 7 8 9 |
|
#4
|
||||
|
||||
|
Code:
#!/bin/bash
for x in {5..9}
do
echo $x
done |
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
loop
Im using grep -A
---------- Post updated at 02:25 AM ---------- Previous update was at 02:20 AM ---------- in my program grep –A $x is lasting to down lines grep -A $x 5 numbers >>file4.txt so I have file called number, numbers saved inside it numbers from 1 to 10 grep –A $x going to start greping from 5 to 10 but what im getting output scramble instead of 5 6 7 8 9 10 |
| Sponsored Links | |
|
|
#6
|
||||
|
||||
|
Code:
#!/bin/bash
for x in {5..9}
do
grep -A$x PATTERN FILE
doneNote: Replace PATTERN with the pattern you want to grep and FILE with the file name you want to grep. ---------- Post updated at 15:36 ---------- Previous update was at 15:29 ---------- Please note that -A option is used to print NUM lines of trailing context after matching lines. |
| Sponsored Links | |
|
|
#7
|
||||
|
||||
|
loop
Is print many lines instead of one round of numbers from 5 to 10 Code:
5 6 7 8 9 10 5 6 7 8 9 10 5 6 7 8 9 10 5 6 7 8 9 10 5 6 7 8 9 10
Last edited by vgersh99; 01-05-2013 at 04:42 PM.. Reason: once again - please use code tag! |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Array Variable being Assigned Values in Loop, But Gone when Loop Completes??? | mrm5102 | Shell Programming and Scripting | 5 | 10-19-2012 10:00 AM |
| HELP PLS - calling function in a while loop ends the loop ?? | newbie_01 | Shell Programming and Scripting | 3 | 05-29-2012 04:38 PM |
| BASH loop inside a loop question | rethink | Shell Programming and Scripting | 4 | 09-15-2010 07:58 AM |
| Null Handling in Until loop. . .loop won't stop | brandono66 | Shell Programming and Scripting | 4 | 11-24-2009 03:57 PM |
| Using variables created sequentially in a loop while still inside of the loop [bash] | DeCoTwc | Shell Programming and Scripting | 2 | 06-23-2009 04:59 PM |
|
|