• ShaunaTheDead@kbin.social
    link
    fedilink
    arrow-up
    2
    ·
    10 months ago

    Serious question, what exactly does do do? In my terminal I can see that do is a command but all I get is bash: syntax error near unexpected token do’and obviously with such a common name it's hard to find information on google about whatdo` actually does.

    • ccf@lemmy.world
      link
      fedilink
      English
      arrow-up
      5
      ·
      edit-2
      10 months ago

      It’s used in loops in bash, like:

      for i in 1 2 3
      do 
          echo "$i"
      done 
      

      or

      while true
      do
          echo "o/"
      done
      
      • ShaunaTheDead@kbin.social
        link
        fedilink
        arrow-up
        1
        ·
        edit-2
        10 months ago

        But then why is it available in my command line terminal as a command that I can use? Like when I type do and then hit TAB twice to list commands that match the output is do done dofsck etc... but when I just enter do in the command line or do --help I get bash: syntax error near unexpected token 'do'

        I would assume that since I can run sudo apt update that I could also run do apt update where it would run it not as a super user. I know just apt update would do that too, but I’m just so curious if it’s possible to use do as a user-level sudo or what else it might be able to do.