I have a line in a text file containing a list of items assigned to a variable ...
ITEMS="$ITEM1 $ITEM2 $ITEM3"
And I would like write a bash script that uses sed to find the line matching ITEMS and append another item to the end of the list within the double quotes, so it results in ...
ITEMS="$ITEM1 $ITEM2 $ITEM3 $ITEM4"
Furthermore, I have the number of the item to add stored in a variable, let's say it's $number. So I'm trying to get it to add $ITEM4$number and have it replace $number with whatever I assigned to that variable, let's say it's the number 4 in this case. How could I best accomplish this? Thanks!
See Question&Answers more detail:os