Re: script to generate names ???
- From: EvilDave <dave.turner@xxxxxxxxxxxxxxxxxxx>
- Date: Fri, 03 Aug 2007 10:49:42 -0700
On Aug 3, 8:29 am, Janis <janis_papanag...@xxxxxxxxxxx> wrote:
On 3 Aug., 14:09, Stephane CHAZELAS <this.addr...@xxxxxxxxxx> wrote:
2007-08-03, 11:16(-00), ramesh.thangam...@xxxxxxxxx:
[...]
[...]awk '
BEGIN {
for (i = 1; i <= 10000; i++)
print "test" i
}'
How abt this one.
#! /bin/sh
i=1
while [ $i -le 10000 ]
do
echo "test$i"
i=`expr $i + 1`
done
That's very bad shell coding practice.
Indeed.
Above, you're calling 3
utilities for each pass in the loop ("[", "echo" and "expr")
instead of only one in total as when using awk.
I think "[" and "echo" are likely built-ins of the shell, so not much
of an issue, but there's also the `...` subprocess to additionally
count on the minus side.
The presence of shell loops is often a good indication of a
poorly written script.
Also the usage of external processes where everything can be done
legible using standard shell features can be an indication.
Why not just printf a $(( )) expression and - if you want to prevent
many calls of touch - pipe the output of the while loop into xargs (as
you suggested upthread).
Janis
--
Stéphane- Hide quoted text -
- Show quoted text -- Hide quoted text -
- Show quoted text -
I hate to say this in shell script forum, but unless the OP has to do
this more than once, I'd just use Excel with test in col 1 and 1 in
col 2. Highlight col 1 and col 2, click on the bottom right tag and
ctrl-drag the columns down until you get test 10000. Next copy into
notepad to strip non-ascii characters, then into Word to do a search
and replace on the tab that will exist between test and the numbers.
Don't hate me. And remember, I only suggest this if you are in a hurry
and don't plan to do it again. Otherewise, write a script.
Dave
.
- Follow-Ups:
- Re: script to generate names ???
- From: Bill Marcum
- Re: script to generate names ???
- From: Hermann Peifer
- Re: script to generate names ???
- From: loki harfagr
- Re: script to generate names ???
- References:
- script to generate names ???
- From: onkar
- Re: script to generate names ???
- From: Stephane CHAZELAS
- Re: script to generate names ???
- From: ramesh . thangamani
- Re: script to generate names ???
- From: Stephane CHAZELAS
- Re: script to generate names ???
- From: Janis
- script to generate names ???
- Prev by Date: Deleting protected directory?
- Next by Date: Determining real user access permissions to files/directories (ls -l doesn't help)
- Previous by thread: Re: script to generate names ???
- Next by thread: Re: script to generate names ???
- Index(es):