Skip to content

How do I run a script for multiple files/glob input? #12611

Answered by Jan9103
Gremious asked this question in Q&A
Discussion options

You must be logged in to vote

i think the thing you are looking for is ...:

def main [...files] {
  print $files
}

->

$ ./test.nu *.txt
╭───┬───────────────────╮
│ 0 │ a.txt             │
│ 1 │ en_wos_nu.txt     │
│ 2 │ english.txt       │
│ 3 │ viewerlist.txt    │
╰───┴───────────────────╯

glob is a datatype like path, date, etc. | into glob changes a string into this filetype and does not expand it.

when passing aruments to a external command (or script), which does not have a definition nu expands globs (*.txt -> multiple arguments) in order to be backwards-compatible with POSIX (and generally easier to use). when defining a nushell function you have to define each argument and expanded globs are multiple argument…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Gremious
Comment options

Answer selected by Gremious
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants