I have a text file, itemlist.txt
, which is comprised of a list of strings like so:
Item1
Item2
Item3
Item4
...
Each string corresponds to a text file (all with the same file extension) in the same directory as the list. In other words, Item1
in the list signifies Item1.txt
in the same directory, and so forth.
What is an efficient method to use this list to edit each file, appending the filename of each file to itself using a Bash shell script? In other words, "Item1" should be the last line of Item1.txt, etc.
I have GUI-based workflow tools to further manipulate these text files once the strings are in place, but I have a LOT to learn about Bash and this has stumped me. Ideally I would like to write a script that accepts user-defined arguments to write to the files along with the filename, but... baby steps!
I think sed
is better for this than echo
, in terms of manipulating the text files, but I am having trouble looping through the text file properly.