0

I have a file with the following line(s):

12/25/18,ALGT,01748X102,ALLEGIANT TRAVL,US,Upgrade,Buy
12/25/18,ALLE,G0176J109,ALLEGION PLC   ,US,Downgrade,Sell
12/25/18,AMSF,03071H100,AMERISAFE INC  ,US,Downgrade,Hold

And so on. I want to replace the first 8 characters with another value. So, the 12/25/18 is in a variable, and the replacement is in another variable.

No matter what I try, I cannot get the replacement to work. Either I get an error, or it does nothing. I've tried about 30 different syntaxes:

sed -i "s/${mmddyy}/${string}/g" $file

Can anyone help?

Cyrus
  • 84,225
  • 14
  • 89
  • 153
Landon Statis
  • 683
  • 2
  • 10
  • 25
  • Or, [How to replace strings containing slashes with sed?](https://stackoverflow.com/questions/16790793/how-to-replace-strings-containing-slashes-with-sed) – Wiktor Stribiżew Dec 27 '18 at 19:28
  • Note that there are advantages to date formats such as 2018-12-25, one of which is that you don't run into the same problem. – Jonathan Leffler Dec 27 '18 at 19:52

0 Answers0