0

Say I have a file of filenames like this:

requests.log
responses.log
resources used.log

and I want to view all of those files. I'd be tempted to do:

$ vi `cat /tmp/list`

but that winds up opening the files "requests.log", "responses.log", "resources", and "used.log" which is not what I want.

I tried

$ cat /tmp/list | xargs -L 99 vi

but that results in the error message "Warning: input not from a terminal"

I've tried editing the file and quoting each of the individual lines, but that was no help either.

Is there a way to do this short of writing some sort of front-end script?

Edward Falk
  • 1,953

1 Answers1

0

Here's what I wound up writing. It works, but it's kind of a non-answer since I was hoping to do this without writing a front end.

#!/usr/bin/env python3

usage = """ Read arguments from a file, one per line, then execute the given command.

usage: lineargs <filename> <cmd> [args] """

import os import sys

argfilename = sys.argv[1] # Get arguments from this file, one per line cmd = sys.argv[2:] # The command and additional arguments

args = open(argfilename, "r").read().splitlines()

cmd.extend(args) os.execvp(cmd[0], cmd)

I didn't bother with error checking, etc. This is just a one-off script.

Edward Falk
  • 1,953