Depends on what you're trying to accomplish.

However, there's not much point running through both grep and sed -
sed's featureset is (roughly) a super-set of grep:

andromeda:tmp polleyj$ cat afile.txt
This is a line
This is another
This is the third line
And this is a fourth.
andromeda:tmp polleyj$ grep line afile.txt | sed 's/third/second/'
This is a line
This is the second line
andromeda:tmp polleyj$ sed -e '/line/!d' -e 's/third/second/' afile.txt
This is a line
This is the second line
andromeda:tmp polleyj$

The various arguments and parameters passed to sed are described under
`man sed`.

You probably also want to read `man bash`, particularly the section
titled "QUOTING".

andromeda:tmp polleyj$ VAR=astring
andromeda:tmp polleyj$ echo $VAR
astring
andromeda:tmp polleyj$ echo "$VAR"
astring
andromeda:tmp polleyj$ echo '$VAR'
$VAR

On Thu, Nov 18, 2010 at 10:38 AM, tony polkich <[email protected]> wrote:
> In -->      grep $VAR afile.txt | sed 's/ ? / newdata/' > anotherfile.txt
>
> what do I insert where the question mark is in sed? $VAR and variations 
> haven't worked.
>
>
>
>
> --
> SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
> Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
>
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to