I've scoured the internet with mixed results. As an amateur I turn to the great minds here.
I have a text file of 80 or so lines. I want to add ".pdf" to the end of each line. (For now that's it)
Most of the internet points toward using "sed". I don't know coding but can figure things out (enough to paint myself into a corner). The closest I've gotten is:
sed 's/$/.pdf/' input
which will print within the shell:
lastlineofinput.pdf
instead of appending ".pdf" to each line within the file.
awk '{NR==1?s=$0 : s=s".pdf"$0}END{print s}' input.txt
did the same thing.
Operators are largely beyond me. I see different solutions involving different amounts of single and double quotations and I'm not sure which ones I should use.
I have had success with finding and replacing text using sed.
sed s/'text1'/'text2'/g inputfile.txt > outputfile.txt
that's a lot more than I knew before today, though admittedly more straightforward (it appears).
The closest I came was one bit of code (I forgot which now) that inserted a period to the end of the very last line. Nowhere else.
I switched to a portable (Mac) and it output the appended .pdf after each line (an improvement) within Terminal but did not modify the original input or the new output files.
...because the highlighted part redirects its output into the 'output' file, not the terminal.
awk, and most other utilities, can't read from and write to the same file at the same time. If you want to do that, overwrite the original file with the new one, once you've checked the data is still okay.
'sed -i' can edit files "in place", but is only available in Linux, can have the unfortunate side-effect of changing the ownership of the file, and -- as noted above -- if you make a mistake with it, you've wrecked your original data.