Reputation: 391
Both sed and g/awk seem very powerful. When I need data manipulated and struggle with syntax I always have answers submitted using both. Personally the syntax of awk is easier for me to grasp (is this common to have a preference?).
I want to spend a few days to trying to study tons of examples of using one or the other, should one specifically be focused on over the other? Does one out perform another in regard to capability? Now onto my question...
I have a .php file that is read and rendered as a json file. It looks like this:
<?php
$selectedSystemStateResults = ["Bird", "Cats", "Cows", "Dog",
"Goats", "Monkey", "Sheep"];
Using sed/awk how could I specify to change "Dog" to "Ducks" ?
Using sed/awk how could I specify to change the 5th variable to "Impalas" ?
The first scenario I would know the name of the variable being changed, the second scenario I would just want the change the variable in a static position.
Upvotes: 0
Views: 37
Reputation: 391
Disregard, overthinking it.
I simply modified the php file so that I could replace lines for now.
<?php
$selectedSystemStateResults = [
"Bird",
"Cats",
"Cows",
"Dog",
"Goats",
"Monkey",
"Penguin"]
;
Upvotes: 1