|
From: littlehelphere on 8 Apr 2008 17:20 I have a script that runs sed through a loop. Everything is working properly except for situations where a username is found with another name. For example I am looking to change the following - foo: foo(a)null.com to foo: /dev/null This works properly but the issue is any other name, such as the ones below will also be changed . So for example dofoo: dofoo(a)null.com is changed to dofoo: do/dev/null and pefoo: pefoo(a)null.com is changed to pefoo: pe/dev/null. I need to pass an argument, etc so that on the entry for "foo" is modified. Any help would be appreciated. Thanks. dofoo: dofoo(a)null.com pefoo: pefoo(a)null.com foo: foo(a)null.com
From: Bill Marcum on 8 Apr 2008 17:27 On 2008-04-08, littlehelphere(a)gmail.com <littlehelphere(a)gmail.com> wrote: > > > I have a script that runs sed through a loop. Everything is working > properly except for situations where a username is found with another > name. For example I am looking to change the following - > foo: foo(a)null.com > to > foo: /dev/null > This works properly but the issue is any other name, such as the > ones below will also be changed . So for example > dofoo: dofoo(a)null.com > is changed to > dofoo: do/dev/null > and > pefoo: pefoo(a)null.com > is changed to > pefoo: pe/dev/null. > I need to pass an argument, etc so that on the entry for "foo" is > modified. Any help would be appreciated. Thanks. > > dofoo: dofoo(a)null.com > pefoo: pefoo(a)null.com > foo: foo(a)null.com > sed 's#^foo:.*#foo: /dev/null#'
From: Ed Morton on 8 Apr 2008 19:24 On 4/8/2008 4:20 PM, littlehelphere(a)gmail.com wrote: > I have a script that runs sed through a loop. Everything is working > properly except for situations where a username is found with another > name. For example I am looking to change the following - > foo: foo(a)null.com > to > foo: /dev/null > This works properly but the issue is any other name, such as the > ones below will also be changed . So for example > dofoo: dofoo(a)null.com > is changed to > dofoo: do/dev/null > and > pefoo: pefoo(a)null.com > is changed to > pefoo: pe/dev/null. > I need to pass an argument, etc so that on the entry for "foo" is > modified. Any help would be appreciated. Thanks. > > dofoo: dofoo(a)null.com > pefoo: pefoo(a)null.com > foo: foo(a)null.com > awk '$1=="foo:"{ $2="/dev/null/" }1' file Ed.
From: littlehelphere on 10 Apr 2008 10:09 On Apr 8, 5:27 pm, Bill Marcum <marcumb...(a)bellsouth.net> wrote: > On 2008-04-08, littlehelph...(a)gmail.com <littlehelph...(a)gmail.com> wrote: > > > > > I have a script that runs sed through a loop. Everything is working > > properly except for situations where a username is found with another > > name. For example I am looking to change the following - > > foo: f...(a)null.com > > to > > foo: /dev/null > > This works properly but the issue is any other name, such as the > > ones below will also be changed . So for example > > dofoo: do...(a)null.com > > is changed to > > dofoo: do/dev/null > > and > > pefoo: pe...(a)null.com > > is changed to > > pefoo: pe/dev/null. > > I need to pass an argument, etc so that on the entry for "foo" is > > modified. Any help would be appreciated. Thanks. > > > dofoo: do...(a)null.com > > pefoo: pe...(a)null.com > > foo: f...(a)null.com > > sed 's#^foo:.*#foo: /dev/null#' I don't see how this is going to work. I may need to expand on what I need to do. The sed command runs in a script with multiple names of users. The file is runs against is a flat file and the syntax may start with a comment in the first filed or may not (i.e - ngj or #foongj). Either way I need a way to get only the specific user I need modifie - in this case ngj. I tried the above and there was no modifiction.
From: Ed Morton on 10 Apr 2008 13:58 On 4/10/2008 9:09 AM, littlehelphere(a)gmail.com wrote: > On Apr 8, 5:27 pm, Bill Marcum <marcumb...(a)bellsouth.net> wrote: > >>On 2008-04-08, littlehelph...(a)gmail.com <littlehelph...(a)gmail.com> wrote: >> >> >> >> >>>I have a script that runs sed through a loop. Everything is working >>>properly except for situations where a username is found with another >>>name. For example I am looking to change the following - >>>foo: f...(a)null.com >>>to >>>foo: /dev/null >>> This works properly but the issue is any other name, such as the >>>ones below will also be changed . So for example >>>dofoo: do...(a)null.com >>>is changed to >>>dofoo: do/dev/null >>>and >>>pefoo: pe...(a)null.com >>>is changed to >>>pefoo: pe/dev/null. >>> I need to pass an argument, etc so that on the entry for "foo" is >>>modified. Any help would be appreciated. Thanks. >> >>>dofoo: do...(a)null.com >>>pefoo: pe...(a)null.com >>>foo: f...(a)null.com >> >>sed 's#^foo:.*#foo: /dev/null#' > > > I don't see how this is going to work. I may need to expand on what I > need to do. The sed command runs in a script with multiple names of > users. The file is runs against is a flat file and the syntax may > start with a comment in the first filed or may not (i.e - ngj or > #foongj). Either way I need a way to get only the specific user I > need modifie - in this case ngj. I tried the above and there was no > modifiction. Then there's something about your input file you aren't telling us. Look: $ cat file foo: foo(a)null.com #foo: foo(a)null.com dofoo: dofoo(a)null.com pefoo: pefoo(a)null.com $ sed 's#^foo:.*#foo: /dev/null#' file foo: /dev/null #foo: foo(a)null.com dofoo: dofoo(a)null.com pefoo: pefoo(a)null.com $ awk '$1=="foo:"{ $2="/dev/null/" }1' file foo: /dev/null/ #foo: foo(a)null.com dofoo: dofoo(a)null.com pefoo: pefoo(a)null.com If that's not what you want, please provide a clearer description of your requirements along with some small set of sample input and the expected output given that input. Ed.
|
Next
|
Last
Pages: 1 2 Prev: Coverting newlines into form feed Next: I Need help in C Script in unix enviroment |