[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
simple prob?
From: |
L A Walsh |
Subject: |
simple prob? |
Date: |
Tue, 29 Jun 2021 13:21:44 -0700 |
User-agent: |
Thunderbird 2.0.0.24 (Windows/20100228) |
I hope a basic question isn't too offtopic.
Say I have some number of jobs running:
jobs|wc -l
3
---
in a function (have tried shopt -s/-u lastpipe; neither way worked)
njobs() {
jobs |wc -l
}
njobs
3
Would like to pass a varname to njobs to store the answer in, like:
njobs() {
jobs|wc -l
#magic puts val in $v
printf {$1:+-v $1} "%s\n" "$v"
}
So I can run:
njobs n
echo "$n"
3
-----------
How can I put the output into '$v'
*without* using a temporary file?
This seems so basic, yet its eluding me.
Could someone throw me a clue-stick?
Tnx!
p.s. - a trivial util func producing jobs:
resleep() { alias my="declare " int="my -i "
int n=${1:-3} t=${2:-99}; echo "$n jobs @ ${t}s:"
while ((0 < n--)); do sleep "$t" & done; }
- simple prob?,
L A Walsh <=
- Re: simple prob?, Greg Wooledge, 2021/06/29
- Re: simple prob?, Kerin Millar, 2021/06/29
- Re: simple prob?, Greg Wooledge, 2021/06/29
- Re: simple prob?, Kerin Millar, 2021/06/29
- Re: simple prob?, L A Walsh, 2021/06/29
- Re: simple prob?, Greg Wooledge, 2021/06/29
- Re: simple prob?, L A Walsh, 2021/06/29
- Re: simple prob?, Greg Wooledge, 2021/06/29
- Re: simple prob?, L A Walsh, 2021/06/30
- Re: simple prob?, Eli Schwartz, 2021/06/29