Search code examples
bashshellunixxmlstarlet

Running command on each line in file


I have FramesList.txt, the file holds 5 .xml filenames. There isn't a path generated because the list is being created by an xml ls > FramesList.txt command.

I want to run an xmlstarlet command on each .xml file listed.

FramesList.txt
FR0391W.xml
FR0921S.xml
FR0193A.xml
FR0192B.xml
FR0132E.xml

How would that look? Is it a loop?


Solution

  • You can use xargs:

    xargs < FramesList.txt -n 1 xmlstartet
    #       ^               ^   ^
    #       |               |   Command to run
    #       |               Max number of arguments (xmlstartet will be called for
    #       |               each line in input file)
    #       Input file