6

How can I use a variable to find a pattern and then add a text, in the same line, after that pattern?

I tried this but it didn't work:

sed -i "/$node_number/ i mytext" "$filepath.csv";
Sergiy Kolodyazhnyy
  • 105,154
  • 20
  • 279
  • 497
  • 3
    Hello and welcome to AskUbuntu. Please [edit] your question to include a minimal example of your input (CSV file) and desired output. – steeldriver Apr 05 '19 at 23:44

1 Answers1

8

This worked:

sed -i "s/$node_number/&mytext/" "filepath.csv";
Sergiy Kolodyazhnyy
  • 105,154
  • 20
  • 279
  • 497