This piece of code:

foreach mod ("`lsmod`")
   echo $mod

outputs each line of lsmod. How can I access the first field, i.e. Module, from each line?

Is there any IDE forcsh or extension for vs code where I can debug csh code?

1 Answer 1

foreach mod ("`lsmod`")
   set ml = ($mod)
   echo "$ml[1]"
  • Parentheses splits line with any type of delimiter or only space?
    – user358527
    Commented Jul 13, 2019 at 16:53
  • 2
    An unquoted variable will be split on any kind of whitespace (spaces, tabs, newlines), but multiple newlines will not be collapsed into a single separator.
    – user313992
    Commented Jul 13, 2019 at 17:04
  • I've another question on accessing fields
    – user358527
    Commented Jul 16, 2019 at 20:22

You must log in to answer this question.