Re: bash script
thomas <list@huno.net> wrote:
>i'm trying to write a simple bash script but with no success so far.
>what this script basically does: it checks if my second isdn line is on
>and if not it tries to connect it until well until its connected :) it
>usually takes more than 2-3 times till the second line is connected.
>
>ok here is the script:
>
>while [ "isdnctrl status ippp1 | grep not" ]; do
Ugh. Using '[' (or 'test', for which it's an alias) in conjunction with
a pipeline is often a sign you're doing the wrong thing. Try this
instead:
while isdnctrl status ippp1 | grep -q not; do
...
done
The -q isn't magic, it just keeps grep a bit quieter. All you need to
understand is that [ ... ] is *not* part of the syntax of while loops
and similar; it's a type of condition all by itself.
This will work in plain sh, not just bash.
>i have a simple "lsof -n | grep lftp | ..." and the output is sth. like:
>
>lftp 27818 root 6w REG 9,0 7597656 20379 /DIR/FILE
>
>now how do i can remove "lftp 27818 root 6w REG 9,0 7597656
> 20379" so that only /DIR/FILE is left? i tried awk but it somehow
>didn't work.
(If you show us what you tried, we might be able to tell you what you're
doing wrong ...)
lsof -n | grep lftp | tr -s ' ' | cut -d' ' -f9
I'm assuming here that there are always eight fields before the
filename. If not, you could try using sed 's,[^/]*,,' or something to
strip off everything before the first slash.
Cheers,
--
Colin Watson [cjw44@flatline.org.uk]
Reply to: