Re: Bash Scripting Question

2013-11-07 Thread Chris Davies
Jonathan Dowland wrote: > On Sun, Nov 03, 2013 at 09:58:58PM +0100, Erwan David wrote: >> Maybe you'll need something like expect to handle this. > I'd second expect, it's probably the best tool for the job in all > non-trivial cases. The "empty-expect" package, perhaps? Chris -- To UNSUBSCRI

Re: Bash Scripting Question

2013-11-05 Thread Zenaan Harkness
On 11/4/13, Thomas H. George wrote: > The script I am trying to write executes a program that requires a > keyboard response. I have experimented with redirecting STDIN but haven't > found the > correct way to make the response. To read a value (perhaps half your "problem"): apt-cache show ... z

Re: Bash Scripting Question

2013-11-04 Thread Karl E. Jorgensen
Hi On Sun, Nov 03, 2013 at 02:35:30PM -0500, Thomas H. George wrote: > The script I am trying to write executes a program that requires a > keyboard response. I have experimented with redirecting STDIN but haven't > found the > correct way to make the response. I found one example that scanned t

Re: Bash Scripting Question

2013-11-04 Thread Jonathan Dowland
The tool 'yes' can be used to write an infinite stream of strings (the default being 'y') to standard output, so if your program needed only a sequence of a fixed string such as 'y', you could do > yes | your-program or > yes "some-other-string" | your-program But if your program is not readin

Re: Bash Scripting Question

2013-11-03 Thread Erwan David
Le 03/11/2013 20:35, Thomas H. George a écrit : > The script I am trying to write executes a program that requires a > keyboard response. I have experimented with redirecting STDIN but haven't > found the > correct way to make the response. I found one example that scanned the > response from apt

Re: Bash Scripting Question

2013-11-03 Thread Cousin Stanley
> The script I am trying to write executes a program > that requires a keyboard response. > A varaible can be set to a keyboard response using a read prompt read -e -p "What do you need ?" xVariable echo $xVariable -- Stanley C. Kitching Human Being Phoenix, Arizon

Bash Scripting Question

2013-11-03 Thread Thomas H. George
The script I am trying to write executes a program that requires a keyboard response. I have experimented with redirecting STDIN but haven't found the correct way to make the response. I found one example that scanned the response from apt-get install for the letter y and fed this back to in

Re: Scripting question

2012-04-17 Thread Daniel Landau
On Tue, Apr 17, 2012 at 4:52 PM, Eduardo M KALINOWSKI wrote: > On Ter, 17 Abr 2012, Chris wrote: >> I would like have the Smtp: replaced with To:  leaving all that follows in >> each line untouched and piped into a new file. > > man sed > Read that too, but try also searching online for "sed tuto

Re: Scripting question

2012-04-17 Thread emmanuel segura
perl -e 'while(<>){chomp; s/root/Root/g; print "$_\n"; }' /etc/passwd Il giorno 17 aprile 2012 15:52, Eduardo M KALINOWSKI < edua...@kalinowski.com.br> ha scritto: > On Ter, 17 Abr 2012, Chris wrote: > >> Firstly I petty much suck at scripting so I need help. >> >> I have a file where each lin

Re: Scripting question

2012-04-17 Thread Eduardo M KALINOWSKI
On Ter, 17 Abr 2012, Chris wrote: Firstly I petty much suck at scripting so I need help. I have a file where each line begins with Smtp: I would like have the Smtp: replaced with To: leaving all that follows in each line untouched and piped into a new file. man sed -- The majority of hu

Scripting question

2012-04-17 Thread Chris
All Firstly I petty much suck at scripting so I need help. I have a file where each line begins with Smtp: I would like have the Smtp: replaced with To: leaving all that follows in each line untouched and piped into a new file. Thanks!! Chris

Re: scripting question: to parse data with varname=value pattern the easiest way?

2010-11-02 Thread Zhang Weiwu, Beijing
On 11/02/2010 05:04 AM, Karl Vogel wrote: >On the other hand, if someone sneaks something like >result_04: dc="3" rm /something/valuable Thank you! very informative, and, kinda fun to read. -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscr

Re: scripting question: to parse data with varname=value pattern the easiest way?

2010-11-01 Thread Karl Vogel
>> On Mon, 01 Nov 2010 15:49:01 +0800, >> Zhang Weiwu said: Z> A program output is like this: Z> result_01: a="23" b="288" c="A_string" ac="34" Z> result_02: a="23" b="28" c="A_string_too" dc="3" Z> Z> I am writing a script to output values of b if b is in the result set. If your

scripting question: to parse data with varname=value pattern the easiest way?

2010-11-01 Thread Zhang Weiwu
Hello. A program output is like this: result_01: a="23" b="288" c="A_string" ac="34" result_02: a="23" b="28" c="A_string_too" dc="3" I am writing a script to output values of b if b is in the result set. It would be rather easy to match value of with regular expression: /b="([^"]*)"/ #

Re: bash scripting question

2010-03-29 Thread Karl Vogel
Here's something I modified as part of a benchmark script called "fdtree". -- Karl Vogel I don't speak for the USAF or my company Dijkstra probably hates me. --Linus Torvalds, in kernel/sched.c #!/bin/bash # How to use xdate/xtime/persec: # # START=$(date "+%s")

Re: bash scripting question

2010-03-29 Thread Ron Johnson
On 2010-03-29 16:35, Mike McClain wrote: [snip] Thanks a lot. Though my error was pointed out as a typo and corrected a while back your solution using " date '+%s' " is much more elegant than what I had done. If you want more (possibly too much) precision: $ date +'%s.%N' -- "History does not

Re: bash scripting question

2010-03-29 Thread Mike McClain
Hi Josep, On Mon, Mar 29, 2010 at 02:28:20PM +0200, Josep M. wrote: > > I found these somewhere time ago. check if is what You need: > Thanks a lot. Though my error was pointed out as a typo and corrected a while back your solution using " date '+%s' " is much more elegant than what I had don

Re: bash scripting question

2010-03-29 Thread Josep M.
Hello. I found these somewhere time ago. check if is what You need: function timer() { if [[ $# -eq 0 ]]; then echo $(date '+%s') else local stime=$1 etime=$(date '+%s') if [[ -z "$stime" ]]; then stime=$etime; fi dt=$((etime - stime)

Re: bash scripting question

2010-03-19 Thread Chris Jackson
Paul E Condon wrote: Try: bgn=$(date +%s) sleep 7 end=$(date +%s) echo "elapsed seconds = " $(( end - bgn )) You might also want to experiment with: ps h -o etime $$ as long as you're happy with it only running under gnu. Prints the elapsed time for the shell. -- Chris Jackson Shadowcat

Re: bash scripting question

2010-03-19 Thread Paul E Condon
On 20100319_101928, Mike McClain wrote: > I've written a function to print elapsed time similar to /usr/bin/time > but can be called at the beginning and end of a script from within > the script. Occasionally I get an error: '8-08: value too great for base' > It's caused by the difference in these

Re: bash scripting question

2010-03-19 Thread Mike McClain
On Fri, Mar 19, 2010 at 06:45:15PM +0100, Sven Joachim wrote: > On 2010-03-19 18:19 +0100, Mike McClain wrote: > > > I've written a function to print elapsed time similar to /usr/bin/time > > but can be called at the beginning and end of a script from within > > the script. Occasionally I get an e

Re: bash scripting question

2010-03-19 Thread Mike McClain
On Fri, Mar 19, 2010 at 10:19:28AM -0700, Mike McClain wrote: typo right herevv > now='09:07:16'; startHr=${now%%:*}; startHR=${startHr#*0}; echo $startHr; Apologies for troubling all. Mike (with egg on face) -- Satisfied user of Linux since 1997. O< ascii ribbon c

Re: bash scripting question

2010-03-19 Thread Wayne
Mike McClain wrote: I've written a function to print elapsed time similar to /usr/bin/time but can be called at the beginning and end of a script from within the script. Occasionally I get an error: '8-08: value too great for base' It's caused by the difference in these 2 command strings but I ca

Re: bash scripting question

2010-03-19 Thread Chris Jackson
Mike McClain wrote: I've written a function to print elapsed time similar to /usr/bin/time but can be called at the beginning and end of a script from within the script. Occasionally I get an error: '8-08: value too great for base' It's caused by the difference in these 2 command strings but I c

Re: bash scripting question

2010-03-19 Thread S Scharf
On Fri, Mar 19, 2010 at 1:19 PM, Mike McClain wrote: > I've written a function to print elapsed time similar to /usr/bin/time > but can be called at the beginning and end of a script from within > the script. Occasionally I get an error: '8-08: value too great for base' > It's caused by the diffe

Re: bash scripting question

2010-03-19 Thread Sven Joachim
On 2010-03-19 18:19 +0100, Mike McClain wrote: > I've written a function to print elapsed time similar to /usr/bin/time > but can be called at the beginning and end of a script from within > the script. Occasionally I get an error: '8-08: value too great for base' > It's caused by the difference i

bash scripting question

2010-03-19 Thread Mike McClain
I've written a function to print elapsed time similar to /usr/bin/time but can be called at the beginning and end of a script from within the script. Occasionally I get an error: '8-08: value too great for base' It's caused by the difference in these 2 command strings but I can't for the life of m

Re: scripting question

2009-07-02 Thread Marc Shapiro
Kumar Appaiah wrote: On Wed, Jul 01, 2009 at 09:28:23AM -0500, Kumar Appaiah wrote: for i in *zzz;do mv "$i" $(echo "$i"|sed 's/^...//'); done But I'd recommend one of these: mrename, krename, gprename, renameutils and more (all apt-gettable, of course). Oh, and I think prename (or just renam

Re: scripting question

2009-07-01 Thread gcrimp
On Wed, Jul 01, 2009 at 07:22:33AM -0700, Marc Shapiro wrote: > I am sure that this is an easy question for those people who do any > reasonable amount of scripting. I'm just not one of them. > > How can I rename all of the files ina directory with the new name being > the old name stripped of

Re: scripting question

2009-07-01 Thread Michael Ekstrand
Marc Shapiro writes: > I am sure that this is an easy question for those people who do any > reasonable amount of scripting. I'm just not one of them. > > How can I rename all of the files ina directory with the new name > being the old name stripped of its leftmost three characters. If all > of

Re: scripting question

2009-07-01 Thread Teemu Likonen
On 2009-07-01 18:20 (+0300), Teemu Likonen wrote: > find -type f -print0 | xargs -0 sh -c 'for file in "$@"; > do dir=$(dirname -- "$file") && base=$(basename -- "$file") && > (cd "$dir" && echo mv -- "$base" "${base#???}"); done' ignore Let's simplify it a bit: find -type f

Re: scripting question

2009-07-01 Thread Teemu Likonen
On 2009-07-01 07:22 (-0700), Marc Shapiro wrote: > How can I rename all of the files ina directory with the new name > being the old name stripped of its leftmost three characters. If all > of the files are off the format: > > xxxy.zzz > > I want the new names to be of th

Re: scripting question

2009-07-01 Thread Boyd Stephen Smith Jr.
In <4a4b7129.7010...@yahoo.com>, Marc Shapiro wrote: >I am sure that this is an easy question for those people who do any >reasonable amount of scripting. I'm just not one of them. > >How can I rename all of the files ina directory with the new name being >the old name stripped of its leftmost thr

Re: scripting question

2009-07-01 Thread Scott Gifford
Marc Shapiro writes: [...] > How can I rename all of the files ina directory with the new name > being the old name stripped of its leftmost three characters. My favorite way to do this is with sed and xargs. First have sed print the current name, then use an regexp to change it to the new

Re: scripting question

2009-07-01 Thread Kumar Appaiah
On Wed, Jul 01, 2009 at 09:28:23AM -0500, Kumar Appaiah wrote: > On Wed, Jul 01, 2009 at 07:22:33AM -0700, Marc Shapiro wrote: > > How can I rename all of the files ina directory with the new name > > being the old name stripped of its leftmost three characters. If > > all of the files are off the

Re: scripting question

2009-07-01 Thread Kumar Appaiah
On Wed, Jul 01, 2009 at 07:22:33AM -0700, Marc Shapiro wrote: > How can I rename all of the files ina directory with the new name > being the old name stripped of its leftmost three characters. If > all of the files are off the format: > > xxxy.zzz > > I want the new na

scripting question

2009-07-01 Thread Marc Shapiro
I am sure that this is an easy question for those people who do any reasonable amount of scripting. I'm just not one of them. How can I rename all of the files ina directory with the new name being the old name stripped of its leftmost three characters. If all of the files are off the format

Re: Scripting Question - tar

2008-07-11 Thread T o n g
On Thu, 10 Jul 2008 17:04:38 -0500, Kent West wrote: >> tar -cvzf - --one-file-system /home | split -b 2000m - Side note since the problem has been solved. You might want to look into dar, which will do splitting for you automatically, as well as many other desired features for backup (incremen

Re: Scripting Question - tar

2008-07-10 Thread Kent West
Owen Townend wrote: Kent West wrote: Am I just not seeing a typo somewhere? Why is my script failing? Hey, You're missing the '-' for stdin tar -czvf - --one-file-system $sourceDir | split -b 2000m - $targetFile Ah, thank you! -- Kent West <")))>< West

Re: Scripting Question - tar

2008-07-10 Thread Owen Townend
> > tar -cvzf - --one-file-system /home | split -b 2000m - > /TERASTATIONBACKUP/GOSHEN/2008/2008-Jul-10.tgz vs > > tar -czvf - --one-file-system $sourceDir | split -b 2000m $targetFile > Am I just not seeing a typo somewhere? Why is my script failing? > > Thanks! Hey, You're missing the '-' fo

Scripting Question - tar

2008-07-10 Thread Kent West
I have this script (stripped down to basics): #!/bin/bash sourceDir='/home/'# Directory you're backing up targetDir='/TERASTATIONBACKUP/GOSHEN/'$(date +%Y)# Destination directory for the tarball targFileBase='GoshensHome'# Desired base part of the tarball's

Re: scripting question

2008-01-06 Thread Matus UHLAR - fantomas
On 21.09.07 08:18, Michael Martinell wrote: > My script is as follows: > #!/bin/sh > > TERM=vt100 > export TERM forcing TERM in script is very bad idea, and in this script also useless. > date && echo " Spam Count" && /bin/more /var/log/syslog | /bin/grep -c > 'identified spam' && echo " " && ec

Re: [OT] Scripting question: the length limit of a list?

2007-11-05 Thread s. keeling
Richard Lyons <[EMAIL PROTECTED]>: > On Thu, Nov 01, 2007 at 01:49:03PM -0700, Mike Bird wrote: > > On Thursday 01 November 2007 13:07, Wei Chen wrote: > > > I would like to write a bash script like the following one: > > > > > > for i in `some program that outputs a word list` > > > do > > > ec

Re: [OT] Scripting question: the length limit of a list?

2007-11-01 Thread Wei Chen
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Mike Bird wrote: > On Thursday 01 November 2007 13:07, Wei Chen wrote: >> I would like to write a bash script like the following one: >> >> for i in `some program that outputs a word list` >> do >> echo $i >> done >> >> where the word list can be ver

Re: [OT] Scripting question: the length limit of a list?

2007-11-01 Thread Ron Johnson
On 11/01/07 15:07, Wei Chen wrote: > Hi, > > I would like to write a bash script like the following one: > > for i in `some program that outputs a word list` > do > echo $i > done > > where the word list can be very very long. I wonder what is the upper bound > limit of the length of word list

Re: [OT] Scripting question: the length limit of a list?

2007-11-01 Thread Richard Lyons
On Thu, Nov 01, 2007 at 01:49:03PM -0700, Mike Bird wrote: > On Thursday 01 November 2007 13:07, Wei Chen wrote: > > I would like to write a bash script like the following one: > > > > for i in `some program that outputs a word list` > > do > > echo $i > > done > > > > where the word list can be

Re: [OT] Scripting question: the length limit of a list?

2007-11-01 Thread Mike Bird
On Thursday 01 November 2007 13:07, Wei Chen wrote: > I would like to write a bash script like the following one: > > for i in `some program that outputs a word list` > do > echo $i > done > > where the word list can be very very long. I wonder what is the upper bound > limit of the length of wor

[OT] Scripting question: the length limit of a list?

2007-11-01 Thread Wei Chen
Hi, I would like to write a bash script like the following one: for i in `some program that outputs a word list` do echo $i done where the word list can be very very long. I wonder what is the upper bound limit of the length of word lists in "for" loop of a bash script, or does it only depend

Re: scripting question

2007-09-22 Thread Jude DaShiell
One possible approach would be to use a few files and use paste on those files where: dfile holds date, mfile holds good messages, sfile holds spam messages tfile is temporary file paste dfile mfile >tfile paste tfile sfile >dfile rm mfile rm sfile rm tfile cat dfile hth. -- To UNSUBSCRIB

Re: scripting question

2007-09-21 Thread Peter Teunissen
On 21-sep-2007, at 15:51, Michael Martinell wrote: Thanks - that was exactly what I was looking for. Now I just need to find a good scripting tutorial. :) Try http://www.tldp.org/LDP/Bash-Beginners-Guide/html/index.html That's where I learned my scripting basics. Peter -- To UNSUBSCRI

RE: scripting question

2007-09-21 Thread Michael Martinell
Thanks - that was exactly what I was looking for. Now I just need to find a good scripting tutorial. :) -Original Message- From: Michael Marsh [mailto:[EMAIL PROTECTED] Sent: Friday, September 21, 2007 8:38 AM To: debian-user@lists.debian.org Subject: Re: scripting question On 9/21/07

Re: scripting question

2007-09-21 Thread Michael Marsh
On 9/21/07, Michael Martinell <[EMAIL PROTECTED]> wrote: > I have a simple script that counts up the number of spam messages each day > and prints the total number into a text field. This is fine as far as it > goes, however I would like to also include the date and the number of > non-spam messag

Re: scripting question

2007-09-21 Thread Neil Watson
Man echo reveals that the -n switch prevents echo from appending a new line. Also, you do not need to use more (or less) with grep. Grep can take a file agrument. Refer to grep's man page for more information. -- Neil Watson | Debian Linux System Administrator| Uptime 6 days ht

scripting question

2007-09-21 Thread Michael Martinell
I have a simple script that counts up the number of spam messages each day and prints the total number into a text field. This is fine as far as it goes, however I would like to also include the date and the number of non-spam messages. I can get this to run, however each piece of information

Re: bash scripting question

2007-05-17 Thread Bob McGowan
Tyler Smith wrote: On 2007-05-17, Bob McGowan <[EMAIL PROTECTED]> wrote: Some general comments, mostly aimed at making your code cleaner without changing what it does. First, both 'echo' and 'printf' put their results on standard out. Your call of 'printf' is inside command substitution, so

Re: bash scripting question

2007-05-16 Thread Alex Samad
On Thu, May 17, 2007 at 03:40:15AM +, Tyler Smith wrote: > On 2007-05-17, Bob McGowan <[EMAIL PROTECTED]> wrote: > > > > Some general comments, mostly aimed at making your code cleaner without > > changing what it does. > > > > First, both 'echo' and 'printf' put their results on standard out.

Re: bash scripting question

2007-05-16 Thread Tyler Smith
On 2007-05-17, Bob McGowan <[EMAIL PROTECTED]> wrote: > > Some general comments, mostly aimed at making your code cleaner without > changing what it does. > > First, both 'echo' and 'printf' put their results on standard out. Your > call of 'printf' is inside command substitution, so its STDOUT

Re: bash scripting question

2007-05-16 Thread Bob McGowan
Tyler Smith wrote: Hi, I've got a question about a short bash script I wrote. I need it to --snipped-- #!/bin/bash lab_num=41 for map_name in aest_90 bush_90 carol_90 comp_90 \ hirs_90 roan_90 swan_90 vir_90 ; do lab_let=$(echo -n $(printf "\\x$(echo $lab_num)")) echo " $la

Re: bash scripting question

2007-05-16 Thread Tyler Smith
On 2007-05-16, Karl E. Jorgensen <[EMAIL PROTECTED]> wrote: >> This was the only way I could figure out to loop from A to H. But >> since it works on hex escape codes, it won't work past 9. Is there a >> cleaner, more general way to do this? > > I think there is: > > #!/bin/bash > > ( cat < A aest_

Re: bash scripting question

2007-05-16 Thread Karl E. Jorgensen
On Wed, May 16, 2007 at 08:46:37PM +, Tyler Smith wrote: > Hi, > > I've got a question about a short bash script I wrote. I need it to > loop over a number of names, and pass a command to grass that includes > two variations of those names. That was easy. Harder was getting > getting a letter

bash scripting question

2007-05-16 Thread Tyler Smith
Hi, I've got a question about a short bash script I wrote. I need it to loop over a number of names, and pass a command to grass that includes two variations of those names. That was easy. Harder was getting getting a letter included in each iteration, starting with A for the first one and going u

Re: quick scripting question - finding occurrence in many lines

2006-11-30 Thread Douglas Tutty
Having all that whitespace in the 'wrong' spot breaks the idea of splitting words based on their being surrounded by whitespace. So get rid of __all__ whitespace. Then use other logic find what you want. E.g. if you want the 'word' following the 'word' processor, find the first occurance of 'proc

Re: quick scripting question - finding occurrence in many lines

2006-11-30 Thread michael
On Wed, 2006-11-29 at 09:36 -0900, Ken Irving wrote: > On Wed, Nov 29, 2006 at 02:32:37PM +, michael wrote: > > I guess a complete rephrase is best. > > > > What I want is "how many processors does each WAITING job in lsf queues > > require?". From 'bhist' I get outputs such as below (see whi

Re: quick scripting question - finding occurrence in many lines

2006-11-29 Thread Ken Irving
On Wed, Nov 29, 2006 at 02:32:37PM +, michael wrote: > I guess a complete rephrase is best. > > What I want is "how many processors does each WAITING job in lsf queues > require?". From 'bhist' I get outputs such as below (see whitespace > anywhere in "num Processors") and cannot determine a

Re: quick scripting question - finding occurrence in many lines

2006-11-29 Thread michael
I guess a complete rephrase is best. What I want is "how many processors does each WAITING job in lsf queues require?". From 'bhist' I get outputs such as below (see whitespace anywhere in "num Processors") and cannot determine a sure way of always parsing it... Thanks, Michael EXAMPLES: ~/b

Re: quick scripting question - finding occurrence in many lines

2006-11-29 Thread michael
On Mon, 2006-11-06 at 01:10 +1100, John O'Hagan wrote: > Or the whole thing could even be done with (I think!): > > #tr -d '\n' < IN | tr ' ' '\n' | grep -B1 Processor | grep -v 'Processor\|--' > > i.e., remove the newlines, replace all the spaces with newlines, then grep > for > the line befo

Re: quick scripting question - finding occurrence in many lines

2006-11-08 Thread Steve Lamb
John O'Hagan wrote: > On Thursday 09 November 2006 03:40, Andrew Sackville-West wrote: >> SO I wonder what happened to the OP? Is he just watching waiting for >> the right solution, or is he long gone? > [...] > OP? What OP? :) The one who hopefully got an A for his answer. -- Ste

Re: quick scripting question - finding occurrence in many lines

2006-11-08 Thread John O'Hagan
On Thursday 09 November 2006 03:40, Andrew Sackville-West wrote: > On Thu, Nov 09, 2006 at 12:52:57AM +1100, John O'Hagan wrote: [...] > > > > while read i ; do > > > > if [[ $(echo "$i" | grep \\-\$ ) ]]; then > > > > i=$( echo "$i" | sed s/-\$//) > >

Re: quick scripting question - finding occurrence in many lines

2006-11-08 Thread Andrew Sackville-West
On Thu, Nov 09, 2006 at 12:52:57AM +1100, John O'Hagan wrote: > > > > tr -d '-\n' > > > | grep -v 'Processor\|--' > > > > [...] > > Aha! You're right, my lines fail on the edge cases, and also when the target > word is hyphenated. > > Your ingenious approach didn't always work either [1]; but

Re: quick scripting question - finding occurrence in many lines

2006-11-08 Thread John O'Hagan
On Wednesday 08 November 2006 03:08, Andrew Sackville-West wrote: > On Wed, Nov 08, 2006 at 02:51:20AM +1100, John O'Hagan wrote: > > I tried this, and found that replacing the newlines with spaces stops the > > grep from working because it puts spaces in the middle of any occurrences > > of "Proce

Re: quick scripting question - finding occurrence in many lines

2006-11-07 Thread Andrew Sackville-West
On Tue, Nov 07, 2006 at 09:36:27AM -0900, Ken Irving wrote: > On Tue, Nov 07, 2006 at 08:08:12AM -0800, Andrew Sackville-West wrote: > > On Wed, Nov 08, 2006 at 02:51:20AM +1100, John O'Hagan wrote: > > > ... > > > > > > Have we done this to death yet? :) > > > > there must be more. I haven't se

Re: quick scripting question - finding occurrence in many lines

2006-11-07 Thread Ken Irving
On Tue, Nov 07, 2006 at 08:08:12AM -0800, Andrew Sackville-West wrote: > On Wed, Nov 08, 2006 at 02:51:20AM +1100, John O'Hagan wrote: > > ... > > > > Have we done this to death yet? :) > > there must be more. I haven't seen any perl junkies provide us with > some permutation of ($*&#^&*%^^@@Pro

Re: quick scripting question - finding occurrence in many lines

2006-11-07 Thread Andrew Sackville-West
On Wed, Nov 08, 2006 at 02:51:20AM +1100, John O'Hagan wrote: > > I tried this, and found that replacing the newlines with spaces stops the > grep > from working because it puts spaces in the middle of any occurrences > of "Processor", but I see what you mean about the edge case. I think this

Re: elegance vs. one-lineness (Was: quick scripting question - finding occurrence in many lines)

2006-11-07 Thread Andrew Sackville-West
On Tue, Nov 07, 2006 at 08:56:55AM -0500, Douglas Tutty wrote: > On Mon, Nov 06, 2006 at 10:26:53PM -0600, Russell L. Harris wrote: > > Andrew Sackville-West wrote: > > >On Mon, Nov 06, 2006 at 01:34:30PM -0800, Steve Lamb wrote: > > >>Depends on what you define as elegant. > > > > > >when I wa

Re: quick scripting question - finding occurrence in many lines

2006-11-07 Thread John O'Hagan
On Tuesday 07 November 2006 02:55, Andrew Sackville-West wrote: > On Tue, Nov 07, 2006 at 01:00:34AM +1100, John O'Hagan wrote: [...] > > You're right; but the OP, Michael, gave the above scenario as his > > problem. If your situation were the case, though, I guess we could use tr > > -d '-' to g

Re: elegance vs. one-lineness (Was: quick scripting question - finding occurrence in many lines)

2006-11-07 Thread Douglas Tutty
On Mon, Nov 06, 2006 at 10:26:53PM -0600, Russell L. Harris wrote: > Andrew Sackville-West wrote: > >On Mon, Nov 06, 2006 at 01:34:30PM -0800, Steve Lamb wrote: > >>Depends on what you define as elegant. > > > >when I was learning to program (mid 80's), we considered anything > >outside of brut

Re: elegance vs. one-lineness (Was: quick scripting question - finding occurrence in many lines)

2006-11-06 Thread Russell L. Harris
Andrew Sackville-West wrote: On Mon, Nov 06, 2006 at 01:34:30PM -0800, Steve Lamb wrote: Depends on what you define as elegant. when I was learning to program (mid 80's), we considered anything outside of brute force to be elegant. Also, anything non-obvious was also considered el

Re: quick scripting question - finding occurrence in many lines

2006-11-06 Thread Douglas Tutty
On Mon, Nov 06, 2006 at 04:58:18PM -0800, Steve Lamb wrote: > Douglas Tutty wrote: > > Sometimes its too easy to keep trying to solve the wrong problem. > > True, but it sure does answer the question "How do you keep a programmer > geek busy?" :) > If you want to keep busy, write this in as

Re: elegance vs. one-lineness (Was: quick scripting question - finding occurrence in many lines)

2006-11-06 Thread Andrew Sackville-West
On Mon, Nov 06, 2006 at 01:34:30PM -0800, Steve Lamb wrote: > > Depends on what you define as elegant. when I was learning to program (mid 80's), we considered anything outside of brute force to be elegant. Also, anything non-obvious was also considered elegant. Anything that used a side-eff

Re: quick scripting question - finding occurrence in many lines

2006-11-06 Thread Steve Lamb
Douglas Tutty wrote: > Sometimes its too easy to keep trying to solve the wrong problem. True, but it sure does answer the question "How do you keep a programmer geek busy?" :) -- Steve C. Lamb | But who decides what they dream? PGP Key: 8B6E99C5 | And dream

Re: quick scripting question - finding occurrence in many lines

2006-11-06 Thread Douglas Tutty
With all the permutations, especially around possible hyphenations, it starts to be easier to look at whatever is creating this hypothetical silly hyphenated file. (note its the file thats silly, not the hypothetical suggestion of hyphens). Sometimes its too easy to keep trying to solve the wrong

elegance vs. one-lineness (Was: quick scripting question - finding occurrence in many lines)

2006-11-06 Thread Steve Lamb
Douglas Tutty wrote: > After thinking about it, yes it can all go in one line. Its more > elegant and doesn't use up memory space but its harder to read to > understand what its doing. Depends on what you define as elegant. I dropped Perl several years ago in preference to Python because I f

Re: quick scripting question - finding occurrence in many lines

2006-11-06 Thread Douglas Tutty
On Sun, Nov 05, 2006 at 05:21:23PM +1100, John O'Hagan wrote: > On Sunday 05 November 2006 16:42, John O'Hagan wrote: > > On Sunday 05 November 2006 09:03, Ken Irving wrote: > > > On Fri, Nov 03, 2006 at 09:56:12PM -0500, Douglas Tutty wrote: > > > > On Fri, Nov 03, 2006 at 08:27:42PM +, michae

Re: quick scripting question - finding occurrence in many lines

2006-11-06 Thread Ken Irving
On Mon, Nov 06, 2006 at 07:55:02AM -0800, Andrew Sackville-West wrote: > On Tue, Nov 07, 2006 at 01:00:34AM +1100, John O'Hagan wrote: > > On Monday 06 November 2006 18:38, David Jardine wrote: > > > On Mon, Nov 06, 2006 at 11:27:58AM +1100, John O'Hagan wrote: > > > > [...] > > > > > > E.g., if

Re: quick scripting question - finding occurrence in many lines

2006-11-06 Thread Paul E Condon
On Tue, Nov 07, 2006 at 01:00:34AM +1100, John O'Hagan wrote: > On Monday 06 November 2006 18:38, David Jardine wrote: > > On Mon, Nov 06, 2006 at 11:27:58AM +1100, John O'Hagan wrote: > > [...] > > > > E.g., if IN contains: > > > > > > junk info 18 Pro > > > > But what if that line were: > > > >

Re: quick scripting question - finding occurrence in many lines

2006-11-06 Thread Andrew Sackville-West
On Tue, Nov 07, 2006 at 01:00:34AM +1100, John O'Hagan wrote: > On Monday 06 November 2006 18:38, David Jardine wrote: > > On Mon, Nov 06, 2006 at 11:27:58AM +1100, John O'Hagan wrote: > > [...] > > > > E.g., if IN contains: > > > > > > junk info 18 Pro > > > > But what if that line were: > > > >

Re: quick scripting question - finding occurrence in many lines

2006-11-06 Thread John O'Hagan
On Monday 06 November 2006 18:38, David Jardine wrote: > On Mon, Nov 06, 2006 at 11:27:58AM +1100, John O'Hagan wrote: [...] > > E.g., if IN contains: > > > > junk info 18 Pro > > But what if that line were: > > junk info 18 Pro- > > which seems more likely? > [...] You're right; but the OP, Mi

Re: quick scripting question - finding occurrence in many lines

2006-11-05 Thread David Jardine
On Mon, Nov 06, 2006 at 11:27:58AM +1100, John O'Hagan wrote: > On Monday 06 November 2006 05:14, Andrew Sackville-West wrote: > > On Sun, Nov 05, 2006 at 10:08:12AM -0800, Steve Lamb wrote: > > > Andrew Sackville-West wrote: > > > > On Mon, Nov 06, 2006 at 01:10:08AM +1100, John O'Hagan wrote: > >

Re: quick scripting question - finding occurrence in many lines

2006-11-05 Thread John O'Hagan
On Monday 06 November 2006 02:53, Andrew Sackville-West wrote: > On Mon, Nov 06, 2006 at 01:10:08AM +1100, John O'Hagan wrote: > > Or the whole thing could even be done with (I think!): > > > > #tr -d '\n' < IN | tr ' ' '\n' | grep -B1 Processor | grep -v > > 'Processor\|--' > > nice. > I just can

Re: quick scripting question - finding occurrence in many lines

2006-11-05 Thread John O'Hagan
On Monday 06 November 2006 05:14, Andrew Sackville-West wrote: > On Sun, Nov 05, 2006 at 10:08:12AM -0800, Steve Lamb wrote: > > Andrew Sackville-West wrote: > > > On Mon, Nov 06, 2006 at 01:10:08AM +1100, John O'Hagan wrote: > > >> Or the whole thing could even be done with (I think!): > > >> > >

Re: quick scripting question - finding occurrence in many lines

2006-11-05 Thread John O'Hagan
On Monday 06 November 2006 05:29, Steve Lamb wrote: > Andrew Sackville-West wrote: > > tr -d '\n' > > > > deletes the new lines > > Ahhh, ok. Was still going off of the previous Python examples which > didn't delete newlines, only replaced them with spaces. Mea Culpa. Oops again! What I mean

Re: quick scripting question - finding occurrence in many lines

2006-11-05 Thread Andrew Sackville-West
On Sun, Nov 05, 2006 at 10:29:42AM -0800, Steve Lamb wrote: > Andrew Sackville-West wrote: > > tr -d '\n' > > > > deletes the new lines > > Ahhh, ok. Was still going off of the previous Python examples which > didn't delete newlines, only replaced them with spaces. Mea Culpa. > I have to

Re: quick scripting question - finding occurrence in many lines

2006-11-05 Thread Steve Lamb
Andrew Sackville-West wrote: > tr -d '\n' > > deletes the new lines Ahhh, ok. Was still going off of the previous Python examples which didn't delete newlines, only replaced them with spaces. Mea Culpa. -- Steve C. Lamb | But who decides what they dream? PGP Key:

Re: quick scripting question - finding occurrence in many lines

2006-11-05 Thread Andrew Sackville-West
On Sun, Nov 05, 2006 at 10:08:12AM -0800, Steve Lamb wrote: > Andrew Sackville-West wrote: > > On Mon, Nov 06, 2006 at 01:10:08AM +1100, John O'Hagan wrote: > >> Or the whole thing could even be done with (I think!): > > >> #tr -d '\n' < IN | tr ' ' '\n' | grep -B1 Processor | grep -v > >> 'Proce

Re: quick scripting question - finding occurrence in many lines

2006-11-05 Thread Steve Lamb
Andrew Sackville-West wrote: > On Mon, Nov 06, 2006 at 01:10:08AM +1100, John O'Hagan wrote: >> Or the whole thing could even be done with (I think!): >> #tr -d '\n' < IN | tr ' ' '\n' | grep -B1 Processor | grep -v 'Processor\|--' > nice. Except for one problem. Look at the OP's post and y

Re: quick scripting question - finding occurrence in many lines

2006-11-05 Thread Andrew Sackville-West
On Mon, Nov 06, 2006 at 01:10:08AM +1100, John O'Hagan wrote: > Or the whole thing could even be done with (I think!): > > #tr -d '\n' < IN | tr ' ' '\n' | grep -B1 Processor | grep -v 'Processor\|--' > nice. A signature.asc Description: Digital signature

Re: quick scripting question - finding occurrence in many lines

2006-11-05 Thread John O'Hagan
On Sunday 05 November 2006 17:21, John O'Hagan wrote: > On Sunday 05 November 2006 16:42, John O'Hagan wrote: > > On Sunday 05 November 2006 09:03, Ken Irving wrote: > > > On Fri, Nov 03, 2006 at 09:56:12PM -0500, Douglas Tutty wrote: > > > > On Fri, Nov 03, 2006 at 08:27:42PM +, michael wrote:

Re: quick scripting question - finding occurrence in many lines

2006-11-04 Thread John O'Hagan
On Sunday 05 November 2006 16:42, John O'Hagan wrote: > On Sunday 05 November 2006 09:03, Ken Irving wrote: > > On Fri, Nov 03, 2006 at 09:56:12PM -0500, Douglas Tutty wrote: > > > On Fri, Nov 03, 2006 at 08:27:42PM +, michael wrote: > > [...] > > > > > eg for > > > > > > > > junk info 18 Pro >

Re: quick scripting question - finding occurrence in many lines

2006-11-04 Thread John O'Hagan
On Sunday 05 November 2006 09:03, Ken Irving wrote: > On Fri, Nov 03, 2006 at 09:56:12PM -0500, Douglas Tutty wrote: > > On Fri, Nov 03, 2006 at 08:27:42PM +, michael wrote: [...] > > > eg for > > > > > > junk info 18 Pro > > > cessor > > > > > > I wish to get the field '18' [...] > > > > S

Re: quick scripting question - finding occurrence in many lines

2006-11-04 Thread Ken Irving
On Sat, Nov 04, 2006 at 01:03:14PM -0900, Ken Irving wrote: > On Fri, Nov 03, 2006 at 09:56:12PM -0500, Douglas Tutty wrote: > > On Fri, Nov 03, 2006 at 08:27:42PM +, michael wrote: > > > I've been trying to do this with 'awk' but am hitting probs (not used > > > awk for ages!) so all offers we

  1   2   >