I'm trying to add 'pp. ' to the following paginations but it doesn't work:
grep -n -o -E --color "\b(pp.\s)?\d{1,3}–\d{2,3}\b" references.txt
3:pp. 610–623
5:102–114
8:58–70
10:245–258
12:99–120
13:70–86
16:172–195
18:389–399
25:1–13
27:104–117
29:503–516
38:501–507
40:1–14
42:450–470
46:759–785
49:1–14
53:50–62
56:1–17
59:1–17
the first pagination (pp. 610–623) is already written as is in the text, this is how the others should be written.
here is the command used:
sed -E "s/(\b(pp.\s)?\d{1,3}–\d{2,3}\b)/(pp. )\1/g" references.txt
sample of references.txt:
References Bender, E., Gebru, T., McMillan-Major, A., & Shmitchel, S. (2021). On the dangers of stochastic parrots: Can language models be too big?. In Proceedings of the 2021 ACM conference on fairness, accountability, and transparency (pp. 610–623). Casal, J. E., & Yoon, J (2023). Frame-based formulaic features in L2 writing pedagogy: Variants, functions, and student perceptions in academic writing. English for Specific Purposes, 71, 102–114. https://doi.org/10.1016/j.esp.2023.03.004 De Costa, P., Lee, J., Rawal, H., & Li, W. (2021). Ethics in applied linguistics. In J. McKinley, & H. Rose (Eds.), The Routledge handbook of research methods in applied linguistics. Routledge. De Costa, P. I., Sterling, S., Lee, J., Li, W., & Rawal, H. (2021). Research tasks on ethics in applied linguistics. Language Teaching, 54(1), 58–70. https://doi.org/ 10.1017/S0261444820000257 Gass, S., Loewen, S., & Plonsky, L. (2021). Coming of age: The past, present, and future of quantitative SLA research. Language Teaching, 54(2), 245–258. https://doi. org/10.1017/S0261444819000430 Hagendorff, T. (2020). The ethics of AI: An evaluation of guidelines. Minds and Machines, 30, 99–120. https://doi.org/10.1007/s11023-020-09517-8 Halleck, G. B., & Connor, U. M. (2006). Rhetorical moves in TESOL conference proposals. Journal of English for Academic Purposes, 5, 70–86. https://doi.org/10.1016/ j.jeap.2005.08.001
No modification is made to the text and I don't have any errors either.
Your regex is wrong. This should work:
sed -E "s/:(pp\. )?(.*)/:pp. \2/g" references.txt
If you want to change the file in place, you should add the -i
flag too:
sed -i -E "s/:(pp\. )?(.*)/:pp. \2/g" references.txt
Also, the first optional capture group (pp\. )?
is present only because you said that the first line already had pagination, so I thought other lines might have it too. If you manually added that and no line has pagination, you can as well remove it:
sed -E "s/:(.*)/:pp. \1/g" references.txt