4 ms·
You can use stdin: echo *.txt | read_stdin_and_get_filenames You can use environment variables: export SPOOLDIR=$HOME/myspooldir; empty_spool_dir
by grymoire1 10y ago
You can use stdin:
echo *.txt | read_stdin_and_get_filenames
You can use environment variables:
export SPOOLDIR=$HOME/myspooldir;
empty_spool_directory
You can use a single argument:
echo *.txt >list_of_filenames
mycomand list_of_filenames
- pavel_lishin 10y ago*.txt gets expanded by bash into a list of arguments. I don't know if this is the case in Windows. ~~Also, the paired asterisks ate some of your comment by treating it as an italics marker.~~ fixed now, thanks.
- vram22 10y ago>.txt gets expanded by bash into a list of arguments. I don't know if this is the case in Windows. (that should read star dot txt in the line above, not sure how to disable the italics meaning of star in posts) I don't think it is the case in Windows, and this seems not to have changed since DOS days, when some programs would be abled to handle wildcards (internally) while others could not, because it was done by the individual programs, not the shell (COMMAND.COM or nowadays CMD.EXE). A quick test: $ python -V Python 3.5.2 $ type test_arg_list.py import sys print(sys.argv) $ python test_arg_list.py a t b ['test_arg_list.py', 'a', 't', 'b'] (that should read t star (not just t) in both the lines above) So wildcards are not expanded. I'm sure there are Windows calls to expand them (there were from the DOS days, like FindFirst and FindNext (awkward approach, IMO), but your program has to actually use them for the expansion to work. In fact, that is what I did, via the Python glob module, in this recent post: Simple directory lister with multiple wildcard arguments: https://jugad2.blogspot.in/2016/12/simple-directory-lister-with-multiple.html https://jugad2.blogspot.in/2016/12/simple-directory-lister-w... Whereas, in Unix, the shell (at least sh / bash) does it automatically for all arguments for all command-line programs, before the program even sees the arguments. This is one of the (many) key benefits of the shell. In fact, all metacharacters are interpreted by the shell and/or the kernel, acting together. This includes redirections, piping, the many special symbols that start with $, backquotes, and many others.