Re: Shell scripting moron
In a message dated: Wed, 17 Jul 2002 11:48:15 EDT Chad R. Henry said: What I have is: count=1 while [ $count -lt 284 ] do count='expr $count + 1' echo http://foo.foo.org/foo[$count].file; /home/user/output done Enclose $count in double quotes within the backticks: count='expr $count + 1' Should work, does for me: $ while [ $count -lt 10 ] do count=`expr $count + 1` echo count = $count done count = 2 count = 3 count = 4 count = 5 count = 6 count = 7 count = 8 count = 9 count = 10 -- Seeya, Paul * To unsubscribe from this list, send mail to [EMAIL PROTECTED] with the text 'unsubscribe gnhlug' in the message body. *
Re: Shell scripting moron
On Wed, Jul 17, 2002 at 11:48:15AM -0400, Chad R. Henry wrote: Okay, I admit I'm a total idiot, I just want a simple script that increments by 1 and outputs a string using the result. What I have is: count=1 while [ $count -lt 284 ] do count='expr $count + 1' ` ` IOW, replace the single quotes with back quotes. -Mark * To unsubscribe from this list, send mail to [EMAIL PROTECTED] with the text 'unsubscribe gnhlug' in the message body. *
Re: Shell scripting moron
Okay, all set here. Thanks to Paul and Mark for pointing out the problems, lack of double quotes and use of single quotes instead of back ticks. See why I'm in sales? :) Chad On 17 Jul 2002 at 11:59, Mark Komarinski wrote: On Wed, Jul 17, 2002 at 11:48:15AM -0400, Chad R. Henry wrote: Okay, I admit I'm a total idiot, I just want a simple script that increments by 1 and outputs a string using the result. What I have is: count=1 while [ $count -lt 284 ] do count='expr $count + 1' ` ` IOW, replace the single quotes with back quotes. -Mark * To unsubscribe from this list, send mail to [EMAIL PROTECTED] with the text 'unsubscribe gnhlug' in the message body. * * To unsubscribe from this list, send mail to [EMAIL PROTECTED] with the text 'unsubscribe gnhlug' in the message body. *
Re: Shell scripting moron
Chad R. Henry [EMAIL PROTECTED] writes: count=1 while [ $count -lt 284 ] do count='expr $count + 1' echo http://foo.foo.org/foo[$count].file; /home/user/output done Use backticks (`...`), not regular quotes ('...'): count=`expr $count + 1` Obviously this isn't working and while I've tried to RTFM and figure out why I realize now why I'm a sales guy. [please configure your mailer to wrap lines] Any sales guy who knows what you know about shell scripts impresses me. I know *very senior* engineers who don't know this stuff. Regards, --kevin -- Kevin D. Clark / Cetacean Networks / Portsmouth, N.H. (USA) cetaceannetworks.com!kclark (GnuPG ID: B280F24E) alumni.unh.edu!kdc * To unsubscribe from this list, send mail to [EMAIL PROTECTED] with the text 'unsubscribe gnhlug' in the message body. *
Re: Shell scripting moron
On Wednesday, July 17, 2002, at 12:13 PM, Kevin D. Clark wrote: [please configure your mailer to wrap lines] Is that the customary setting? I thought that the burden of wrapping was upon the client, so that URLs don't get broken, etc. (I'm not challenging you, I really am curious.) Any sales guy who knows what you know about shell scripts impresses me. I know *very senior* engineers who don't know this stuff. Is that because they do it in Perl and therefore never use bash, or because they don't program? (I hope it's the latter b/c that bodes well for my current job hunt [server side programming]) Erik * To unsubscribe from this list, send mail to [EMAIL PROTECTED] with the text 'unsubscribe gnhlug' in the message body. *
Re: Shell scripting moron
Any sales guy who knows what you know about shell scripts impresses me. I know *very senior* engineers who don't know this stuff. GNHLUG is indeed graced with all kinds of talent - enough to fully staff an enterprise, I'll bet. We missed a golden opportunity by not having an IPO back during 1999-2001 timeframe when you didn't even need a business plan... * To unsubscribe from this list, send mail to [EMAIL PROTECTED] with the text 'unsubscribe gnhlug' in the message body. *
Re: Shell scripting moron
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 At some point hitherto, Erik Price hath spake thusly: On Wednesday, July 17, 2002, at 12:13 PM, Kevin D. Clark wrote: [please configure your mailer to wrap lines] Is that the customary setting? Yes. I thought that the burden of wrapping was upon the client, so that URLs don't get broken, etc. (I'm not challenging you, I really am curious.) Line wrapping will (or should) not break URLs. It wraps (or should) on whitespace. Most clients will treat unwrapped paragraphs as one long line, which causes a variety of headaches for both viewing, and especially for replying to, such a message. It is generally considered good Netiquette to wrap your lines at something less than 80 characters -- 72 seems to be a common number. Many people still use text-based clients in an 80-character terminal window (myself included), and this number allows a line to fit all on one line, while still leaving room for a few levels of quoting characters, for when the message is replied to. Any sales guy who knows what you know about shell scripts impresses me. I know *very senior* engineers who don't know this stuff. Is that because they do it in Perl and therefore never use bash, or because they don't program? (I hope it's the latter b/c that bodes well for my current job hunt [server side programming]) Shell programming has become somewhat of a lost art, increasingly relegated largely to those who are system administrators. Perl has taken over as the scripting language of choice, as it is very portable, and very mature, and substantially faster than most of the shells. Makes for an easy time writing portable, maintainable scripts for automating a variety of tasks on many different platforms. Also, many who are engineers rarely have a need for a scripting language, prefering to code in a compileable language such as C. - -- Derek Martin [EMAIL PROTECTED] - - I prefer mail encrypted with PGP/GPG! GnuPG Key ID: 0x81CFE75D Retrieve my public key at http://pgp.mit.edu Learn more about it at http://www.gnupg.org -BEGIN PGP SIGNATURE- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE9NZ0XdjdlQoHP510RAujSAJ977IEUffhhlfllfN+/FHhQIBnBqgCeO7eU M6x2HaW1C/5Db8mKLocyi0Y= =3qxR -END PGP SIGNATURE- * To unsubscribe from this list, send mail to [EMAIL PROTECTED] with the text 'unsubscribe gnhlug' in the message body. *
Re: Shell scripting moron
Optionally, you can write it like this for some shells (ksh, bash). The arithmetic is done in the same shell. ie. it is not invoking an external expr for each iteration of the loop. count=1 while [ $count -lt 284 ] do (( count=count+1 )) echo $count done -Andy Chad R. Henry wrote: Okay, I admit I'm a total idiot, I just want a simple script that increments by 1 and outputs a string using the result. What I have is: count=1 while [ $count -lt 284 ] do count='expr $count + 1' echo http://foo.foo.org/foo[$count].file; /home/user/output done Obviously this isn't working and while I've tried to RTFM and figure out why I realize now why I'm a sales guy. Is anyone willing to help the stupid suit? Chad * To unsubscribe from this list, send mail to [EMAIL PROTECTED] with the text 'unsubscribe gnhlug' in the message body. * * To unsubscribe from this list, send mail to [EMAIL PROTECTED] with the text 'unsubscribe gnhlug' in the message body. *
Re: Shell scripting moron
On Wednesday, July 17, 2002, at 12:44 PM, Bill Studley wrote: timtowtdi ;-) Hey, if you're going to say that, then you have to use this: perl -e 'for($c=1;$c284;$c++){printhttp://foo.foo.org/foo$c.file\n;}'somefile. txt ;) Erik * To unsubscribe from this list, send mail to [EMAIL PROTECTED] with the text 'unsubscribe gnhlug' in the message body. *
Re: Shell scripting moron
Erik Price [EMAIL PROTECTED] writes: Any sales guy who knows what you know about shell scripts impresses me. I know *very senior* engineers who don't know this stuff. Is that because they do it in Perl and therefore never use bash, or because they don't program? (I hope it's the latter b/c that bodes well for my current job hunt [server side programming]) I totally messed up when I answered this question in a previous email. Why don't (software) engineers know shell scripting? Is this the question? If this is the question, then I guess I'd have to answer: o I dunno. And... o Some software engineers I know come from more of a Windows background. They might have some VB experience, or more likely they know how to write DOS batch scripts. When they come to find themselves in a Unix environment, they assume that Unix shell-scripts are pretty similar to DOS batch scripts (which are pretty horrible). This comparison is false, but that's the perception. Shell scripts are like a convenient glue or maybe like a handy power tool (think cordless screwdriver). There's some initial learning curve, but after you're over this curve, you've got a *very* handy job skill. People without this skill are forced to do things the hard way (*). * Like for example, the people I know who know that they want to make a textual replacement in, oh, a thousand files -- they either write a custom C program to do this, or else they make the changes *by hand*. Duh... --kevin -- Kevin D. Clark / Cetacean Networks / Portsmouth, N.H. (USA) cetaceannetworks.com!kclark (GnuPG ID: B280F24E) alumni.unh.edu!kdc * To unsubscribe from this list, send mail to [EMAIL PROTECTED] with the text 'unsubscribe gnhlug' in the message body. *
Re: Shell scripting moron
Erik Price wrote: On Wednesday, July 17, 2002, at 12:44 PM, Bill Studley wrote: timtowtdi ;-) Hey, if you're going to say that, then you have to use this: perl -e 'for($c=1;$c284;$c++){printhttp://foo.foo.org/foo$c.file\n;}'somefile. txt ;) Erik I knew there was a one liner in there someplace :-D * To unsubscribe from this list, send mail to [EMAIL PROTECTED] with the text 'unsubscribe gnhlug' in the message body. *
Re: Shell scripting moron
In a message dated: Wed, 17 Jul 2002 13:48:10 EDT Bill Studley said: Erik Price wrote: Hey, if you're going to say that, then you have to use this: perl -e 'for($c=1;$c284;$c++){printhttp://foo.foo.org/foo$c.file\n;}'somefile.txt I knew there was a one liner in there someplace :-D There always is, but shouldn't we make it a litte more efficient? perl -e 'for $c (1..284) {print http://foo.foo.org/foo${c}.file\n;}' file.txt Or, better: perl -e 'map { print http://foo.foo.org/foo$_\n} 1...284' file.txt :) -- Seeya, Paul It may look like I'm just sitting here doing nothing, but I'm really actively waiting for all my problems to go away. If you're not having fun, you're not doing it right! * To unsubscribe from this list, send mail to [EMAIL PROTECTED] with the text 'unsubscribe gnhlug' in the message body. *
Re: Shell scripting moron
This is my one-liner : for i in `seq 1 10`; do echo http://foo.foo.org/foo$i.html; done file.txt seq is a part of the gnu shell-util package. The RedHat 7.3 rpm is called sh-utils. man seq for more information. On Wed, Jul 17, 2002 at 01:48:10PM -0400, Bill Studley wrote: Erik Price wrote: On Wednesday, July 17, 2002, at 12:44 PM, Bill Studley wrote: timtowtdi ;-) Hey, if you're going to say that, then you have to use this: perl -e 'for($c=1;$c284;$c++){printhttp://foo.foo.org/foo$c.file\n;}'somefile. txt ;) Erik I knew there was a one liner in there someplace :-D * To unsubscribe from this list, send mail to [EMAIL PROTECTED] with the text 'unsubscribe gnhlug' in the message body. * -- --- Steven Knight #include standard_disclaimer.h [EMAIL PROTECTED] IM : skkataim This was but a prelude; where books are burnt human-beings will be burnt in the end. --Heinrich Heine, 1820 Those who cannot remember the past are condemned to repeat it. --Santayana Will I ever use calculus again? No. There is no connection between calculus and anything you will do in life. We use it simply as a way to trick people into becoming mathematicians. ~~ * To unsubscribe from this list, send mail to [EMAIL PROTECTED] with the text 'unsubscribe gnhlug' in the message body. *
Re: Shell scripting moron
On Wednesday, July 17, 2002, at 01:05 PM, Kevin D. Clark wrote: Shell scripts are like a convenient glue or maybe like a handy power tool (think cordless screwdriver). There's some initial learning I see shell scripts come with a lot of software, and linux distributions, but it seems that when someone writes their -own- script/tool, they do it in Perl (at least I do). For instance, Perl's regexes are a lot easier and more precise (to me) than the bash's globbing system. Well, I guess that's not fair, I just know a little bit more Perl than I do bash. But what I'm wondering is if there really are a lot of Unix systems out there that don't come with Perl, to the extent that a script accompanying an application should be written in bash or csh over Perl. (Not counting the super-specialized systems like handhelds which might not have Perl for space reasons.) * Like for example, the people I know who know that they want to make a textual replacement in, oh, a thousand files -- they either write a custom C program to do this, or else they make the changes *by hand*. Duh... I cannot find it for the life of me, but somewhere in the [EMAIL PROTECTED] archives (that damnable WebObject interface is terrible and doesn't return the matches) is a quotation by Douglas Adams. He describes the joys of spending fifteen minutes writing a script that he could have done by hand in five minutes. Come on, we've all done it. Admit it... Erik * To unsubscribe from this list, send mail to [EMAIL PROTECTED] with the text 'unsubscribe gnhlug' in the message body. *
Re: Shell scripting moron
Erik Price said: script/tool, they do it in Perl (at least I do). For instance, Perl's regexes are a lot easier and more precise (to me) than the bash's globbing system. Well, I guess that's not fair, I just know a little Sometimes globbing is easier to work with then regex. I think Perl can do globbing if you want. Of course if you want to do something complex, regex can do much more then globbing. bit more Perl than I do bash. But what I'm wondering is if there really are a lot of Unix systems out there that don't come with Perl, to the Solaris, HP-UX, AIX, Irix, Tru64 (?). If you deal with older systems: SunOS, Ultrix, OSF and older versions of all of the above, for sure. Yes, perl is available on all of these, but it's an add on. I've also been in an environment where I couldn't install perl w/o 6 months of justification (think DOD B2 systems). If you're dealing with the single floppy linux distributions, perl is usually left off. Some linuxen had perl as an add on (slackware). Especially the older versions. I think some of the BSDs are looking toward moving perl to the optional sections too. I had to break into an Ultrix system from the boot CD once. Can you belive they didn't put ls on there? I had to use echo *. System startup scripts shouldn't assume more then sh and the programs in /bin. Solaris Jumpstart works like this too. extent that a script accompanying an application should be written in bash or csh over Perl. (Not counting the super-specialized systems like csh scripting!?!?! You heathen! :-) As someone who has fixed ported many csh scripts, don't do it! I found problems porting csh from SunOS to Solaris even! handhelds which might not have Perl for space reasons.) Such as my 1 floppy system examples. I cannot find it for the life of me, but somewhere in the [EMAIL PROTECTED] archives (that damnable WebObject interface is terrible and doesn't return the matches) is a quotation by Douglas Adams. He describes the joys of spending fifteen minutes writing a script that he could have done by hand in five minutes. Come on, we've all done it. Admit it... Absolutely. If I don't have to do that task again, that script was a waste. Until the 4th time. -- --- Tom Buskey * To unsubscribe from this list, send mail to [EMAIL PROTECTED] with the text 'unsubscribe gnhlug' in the message body. *
Re: Shell scripting moron
IMHO PERL is more of a programming language. Every tried to do anything rather complex in Bourne :-) On 17 Jul 2002 at 14:26, Erik Price wrote: On Wednesday, July 17, 2002, at 01:05 PM, Kevin D. Clark wrote: Shell scripts are like a convenient glue or maybe like a handy power tool (think cordless screwdriver). There's some initial learning I see shell scripts come with a lot of software, and linux distributions, but it seems that when someone writes their -own- script/tool, they do it in Perl (at least I do). For instance, Perl's regexes are a lot easier and more precise (to me) than the bash's globbing system. Well, I guess that's not fair, I just know a little bit more Perl than I do bash. But what I'm wondering is if there really are a lot of Unix systems out there that don't come with Perl, to the extent that a script accompanying an application should be written in bash or csh over Perl. (Not counting the super-specialized systems like handhelds which might not have Perl for space reasons.) * Like for example, the people I know who know that they want to make a textual replacement in, oh, a thousand files -- they either write a custom C program to do this, or else they make the changes *by hand*. Duh... I cannot find it for the life of me, but somewhere in the [EMAIL PROTECTED] archives (that damnable WebObject interface is terrible and doesn't return the matches) is a quotation by Douglas Adams. He describes the joys of spending fifteen minutes writing a script that he could have done by hand in five minutes. Come on, we've all done it. Admit it... Erik * To unsubscribe from this list, send mail to [EMAIL PROTECTED] with the text 'unsubscribe gnhlug' in the message body. * -- Jerry Feldman [EMAIL PROTECTED] Associate Director Boston Linux and Unix user group http://www.blu.org PGP key id:C5061EA9 PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9 * To unsubscribe from this list, send mail to [EMAIL PROTECTED] with the text 'unsubscribe gnhlug' in the message body. *