LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-05-2014, 09:36 AM   #16
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,500

Rep: Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867

How about:
Code:
while read _
do
  <your stuff to be repeated up to 10 times>
done< <(grep -m10 up /opt/tmp/vpnclientstatus)
 
Old 06-05-2014, 10:48 AM   #17
metaschima
Senior Member
 
Registered: Dec 2013
Distribution: Slackware
Posts: 1,982

Rep: Reputation: 491Reputation: 491Reputation: 491Reputation: 491Reputation: 491
Quote:
Originally Posted by pan64 View Post
I still do not understand it. The code in post #6 will not count the "up"s, but will try to start vpn ten times (if "up" was not found). And also at the tenth try it will finish the for loop and report "VPNbook NOT restablished " without checking the result.
Correct me if I'm wrong, but this is NOT about finding the word "up" ten times in a file. This is about trying to find the word "up" in a log once, but with 10 as the break limit otherwise it would be an infinite loop.

For this purpose the above scripts, except for the first/OP work fine.
 
Old 06-05-2014, 11:41 AM   #18
bilbonix
LQ Newbie
 
Registered: Nov 2012
Posts: 21

Original Poster
Rep: Reputation: Disabled
You are correct and it is working great. Thanks for the assistance all.
 
Old 06-05-2014, 05:27 PM   #19
bilbonix
LQ Newbie
 
Registered: Nov 2012
Posts: 21

Original Poster
Rep: Reputation: Disabled
Aactually this didn't work for i in {1..10}

I had to change it to "for i in 1 2 3 4 5 6 7 8 9 10

Why would that be
 
Old 06-05-2014, 05:39 PM   #20
metaschima
Senior Member
 
Registered: Dec 2013
Distribution: Slackware
Posts: 1,982

Rep: Reputation: 491Reputation: 491Reputation: 491Reputation: 491Reputation: 491
Could be a compatibility issue. You can try:

Code:
for i in $(seq 1 10)
as it is more portable.
 
Old 06-05-2014, 06:24 PM   #21
bilbonix
LQ Newbie
 
Registered: Nov 2012
Posts: 21

Original Poster
Rep: Reputation: Disabled
seq not found, maybe because its just a router os, I'll stick with the long version.
 
Old 06-05-2014, 09:26 PM   #22
metaschima
Senior Member
 
Registered: Dec 2013
Distribution: Slackware
Posts: 1,982

Rep: Reputation: 491Reputation: 491Reputation: 491Reputation: 491Reputation: 491
Oh, so this is going to run on a router, well then commands will be missing, so use the long version for now, or you can use a while loop with a counter.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating an alias in ksh that uses grep and includes 'grep -v grep' doug248 Linux - Newbie 2 08-05-2012 02:07 PM
[bash-script] A question about using grep in the script thomas2004ch Linux - Software 2 03-05-2012 03:27 AM
Using grep for a script iongrey Programming 3 03-24-2009 07:55 PM
grep script kaiserbeto Linux - Newbie 2 11-15-2006 01:50 PM
bash script with grep and sed: sed getting filenames from grep odysseus.lost Programming 1 07-17-2006 11:36 AM


All times are GMT -5. The time now is 03:17 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration