Prev: Want to write a script to note specific IP addresses.
Next: get current timestamp in microseconds or milliseconds
From: Ed Morton on 20 Oct 2009 09:01 Kevin Collins wrote: > On 2009-10-19, Ed Morton <mortonspam(a)gmail.com> wrote: >> Sivaram Neelakantan wrote: >>> I plot a lot of graphs in my shell script and I'd like to run it as a >>> background job. This is what I have currently >>> >>> gnuplot < $GPLOTDIR/${amc}/${FILENAME}_${PERIOD}.gplot >>> >>> within a loop. >> OK, but quote your variables unless you have a specific reason not to. > > Why? Just curious, but I don't see a reason to quote variables in this case... > They will be interpolated either way. "amc", for example, should contain spaces: $ > "one file" $ amc="one file" $ ls $amc ls: cannot access one: No such file or directory ls: cannot access file: No such file or directory $ ls "$amc" one file Regards, Ed.
From: Sivaram Neelakantan on 20 Oct 2009 13:52 Arcege <arcege(a)gmail.com> writes: [snipped 15 lines] > > Yes, if you add a "&" at the end, it will go to the background. But > not as a job. Job control is available on interactive shells. You > can wait for all pipelines (background processes) that have been > placed in the background with the 'wait' command. > # call each in the background > for file in dir/*; do > program $file & > done > # now wait for them all > wait > > However, it may not be the most efficient use of the disk to have too > many of them running at once. > > -Arcege Thanks Arcege and Ed, I'll try that. And as for spaces in the names, I'm reading almost all the stuff from a bunch of config files that I created. I don't create files or directories with spaces in their names. unless it's some typo of mine. sivaram --
From: Ed Morton on 20 Oct 2009 16:01 On Oct 20, 12:52 pm, Sivaram Neelakantan <nsivaram....(a)gmail.com> wrote: > Arcege <arc...(a)gmail.com> writes: > > [snipped 15 lines] > > > > > > > > > Yes, if you add a "&" at the end, it will go to the background. But > > not as a job. Job control is available on interactive shells. You > > can wait for all pipelines (background processes) that have been > > placed in the background with the 'wait' command. > > # call each in the background > > for file in dir/*; do > > program $file & > > done > > # now wait for them all > > wait > > > However, it may not be the most efficient use of the disk to have too > > many of them running at once. > > > -Arcege > > Thanks Arcege and Ed, I'll try that. > > And as for spaces in the names, I'm reading almost all the stuff from > a bunch of config files that I created. I don't create files or > directories with spaces in their names. unless it's some typo of > mine. > > sivaram > --- Hide quoted text - > > - Show quoted text - OK, but quoting variables is just good common practice and one day you'll either be glad you got into the habit or wish you had got into the habit! Ed.
From: Kevin Collins on 20 Oct 2009 19:20 On 2009-10-20, Ed Morton <mortonspam(a)gmail.com> wrote: > Kevin Collins wrote: >> On 2009-10-19, Ed Morton <mortonspam(a)gmail.com> wrote: >>> Sivaram Neelakantan wrote: >>>> I plot a lot of graphs in my shell script and I'd like to run it as a >>>> background job. This is what I have currently >>>> >>>> gnuplot < $GPLOTDIR/${amc}/${FILENAME}_${PERIOD}.gplot >>>> >>>> within a loop. >>> OK, but quote your variables unless you have a specific reason not to. >> >> Why? Just curious, but I don't see a reason to quote variables in this case... >> They will be interpolated either way. > > "amc", for example, should contain spaces: > > $ > "one file" > $ amc="one file" > $ ls $amc > ls: cannot access one: No such file or directory > ls: cannot access file: No such file or directory > $ ls "$amc" > one file Yes, very good point. I guess I am used to working with sane people :) Thanks, Kevin
From: Barry Margolin on 21 Oct 2009 02:24
In article <slrnhdshef.emv.spamtotrash(a)vai.unix-guy.com>, Kevin Collins <spamtotrash(a)toomuchfiction.com> wrote: > On 2009-10-20, Ed Morton <mortonspam(a)gmail.com> wrote: > > Kevin Collins wrote: > >> On 2009-10-19, Ed Morton <mortonspam(a)gmail.com> wrote: > >>> Sivaram Neelakantan wrote: > >>>> I plot a lot of graphs in my shell script and I'd like to run it as a > >>>> background job. This is what I have currently > >>>> > >>>> gnuplot < $GPLOTDIR/${amc}/${FILENAME}_${PERIOD}.gplot > >>>> > >>>> within a loop. > >>> OK, but quote your variables unless you have a specific reason not to. > >> > >> Why? Just curious, but I don't see a reason to quote variables in this > >> case... > >> They will be interpolated either way. > > > > "amc", for example, should contain spaces: > > > > $ > "one file" > > $ amc="one file" > > $ ls $amc > > ls: cannot access one: No such file or directory > > ls: cannot access file: No such file or directory > > $ ls "$amc" > > one file > > Yes, very good point. I guess I am used to working with sane people :) I guess you don't work with people who mostly work in GUIs rather than CLIs. It's very common for them to use phrases when naming files. E.g. "September Expenses" rather than "september-expenses". -- Barry Margolin, barmar(a)alum.mit.edu Arlington, MA *** PLEASE post questions in newsgroups, not directly to me *** *** PLEASE don't copy me on replies, I'll read them in the group *** |