I want to remove the template with sed, only on the second appearance. Here is what I want to remove the template, but in the second case.
What is in the .csv file:
a,Name(null)abc.csv,c,d,Name(null)abc.csv,f a,Name(null)acb.csv,c,d,Name(null)acb.csv,f a,Name(null)cba.csv,c,d,Name(null)cba.csv,f
Required Conclusion:
a,Name(null)abc.csv,c,d,Name,f a,Name(null)acb.csv,c,d,Name,f a,Name(null)cba.csv,c,d,Name,f
This is what I tried:
sed -r 's/(\(null)\).*csv//' file.csv
The problem here is that the regex is too greedy, but I can't do it, stop it. I also tried this to skip the first occurrence of "null":
sed -r '0,/null/! s/(\(null)\).*csv//' file.csv
Also tried, but greedy regex is still a problem.
sed -r 's/(\(null)\).*csv//2' file.csv
I read that ? can make the regular expression βlazy,β but I can't make it a workout.
sed -r 's/(\(null)\).*?csv//' file.csv