Re: Scripting question

2002-12-04 Thread Thierry ITTY
>> >From a script: main.sh, I need to: >> 1. Copy file ./x to /tmp/x >> 2. Read a variable from stdin, for example: read VALUE >> 3. Search through file /tmp/x for the keyword REPLACE, and replace it with ${VALUE} >> >> I can't seem to figure out what combination of sed, perl, whatever I can use.

RE: Scripting question

2002-12-04 Thread Niessen, Klif
Just replace the single quotes with double quotes. Single quotes are keeping the $vars from being evaluated. sed "s/REPLACE/${VALUE}/g" /tmp/x > /tmp/x.new Klif -- redhat-list mailing list unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe https://listman.redhat.com/mailman/listinf

Re: Scripting question

2002-12-04 Thread Johnathan Bailes
On Tue, 2002-12-03 at 15:54, Shaw, Marco wrote: > >From a script: main.sh, I need to: > 1. Copy file ./x to /tmp/x > 2. Read a variable from stdin, for example: read VALUE > 3. Search through file /tmp/x for the keyword REPLACE, and replace it with ${VALUE} > > I can't seem to figure out what comb

Re: Scripting question

2002-12-03 Thread Bret Hughes
On Tue, 2002-12-03 at 14:54, Shaw, Marco wrote: > >From a script: main.sh, I need to: > 1. Copy file ./x to /tmp/x > 2. Read a variable from stdin, for example: read VALUE > 3. Search through file /tmp/x for the keyword REPLACE, and replace it with ${VALUE} > > I can't seem to figure out what comb

Re: Scripting question on a "case" construct (THANKS!)

2002-07-19 Thread Joe Nestlerode
Thanks to both of you for responding. The empty quotes works best for what I wanted to do (which I should have been clearer on in the first place). I wanted to make the first choice in a menu the "default", ie, just hit , and the empty quotes allow me to do that: echo -e " Your selection, pl

Re: Scripting question on a "case" construct

2002-07-18 Thread Cameron Simpson
On 14:05 18 Jul 2002, Joe Nestlerode <[EMAIL PROTECTED]> wrote: | Can you put a carriage return (enter) as one of the choices in a 'case' | construct? *) will catch it, but I need that for the "Invalid Choice" | catch-all at the end. I couldn't find it in the documentation; is this | possible

Re: Scripting question on a "case" construct

2002-07-18 Thread Stephen Spalding
Now that I think about it, you asked for how to check for a response of just cr-lf. Here's what I should have sent you: #!/bin/bash echo "Please answer yes or no: " read answer if [ x"$answer" = x"" ]; then echo echo "*** Invalid Response! ***" echo exit -1 fi

Re: Scripting question on a "case" construct

2002-07-18 Thread Stephen Spalding
I think what I would do is put a check in for an empty response before the case statement is ever reached. Here's an example of what I mean: #!/bin/bash echo "Please answer yes or no: " read answer if [[ x"$answer" != x"yes" && x"$answer" != x"no" ]]; then echo echo "*** Invalid

Re: Scripting question - script to find and delete files

2002-07-12 Thread Saul Arias
On Fri, 2002-07-12 at 15:56, Joe Nestlerode wrote: > Thank you, that works beautifully. I modified it slightly to allow a > user to enter a search pattern on the command line, to wit: > > #!/bin/sh > > echo -e "Enter a file or pattern to search for...\n" > read file > > for i in `find . -name

Re: Scripting question - script to find and delete files

2002-07-12 Thread Joe Nestlerode
Saul, Thank you, that works beautifully. I modified it slightly to allow a user to enter a search pattern on the command line, to wit: #!/bin/sh echo -e "Enter a file or pattern to search for...\n" read file for i in `find . -name "$file"` do rm -i $i done exit 0 Thanks again! Joe [EMA

Re: Scripting question - script to find and delete files

2002-07-12 Thread Saul Arias
On Fri, 2002-07-12 at 13:13, Joe Nestlerode wrote: > I'm trying to write a simple script to search a directory tree for a > file pattern (specified as an argument with a wildcard, ie, testfile* or > *.jpg), and then delete matching files after first prompting the user > for a y/n. (yes=delete,