GNU social JP
  • FAQ
  • Login
GNU social JPは日本のGNU socialサーバーです。
Usage/ToS/admin/test/Pleroma FE
  • Public

    • Public
    • Network
    • Groups
    • Featured
    • Popular
    • People

Embed Notice

HTML Code

Corresponding Notice

  1. Embed this notice
    Ramin Honary (ramin_hal9001@fe.disroot.org)'s status on Monday, 20-Oct-2025 10:54:18 JSTRamin HonaryRamin Honary
    in reply to
    • Miakoda

    @hellomiakoda @hellomiakoda thanks, I have a pretty good idea of where you should start learning, but I’ll have to search around a bit for some resources you can use.

    Without going into too much detail, let me just breifly explain the example I wrote above. First of all, it is basically a useless command so I would not recommend using it, I just wanted an example that would show how lexing works.

    Yes the echo will take it’s arguments and print them. The * character is a special token called a “glob pattern” that tells the shell to substitute that token with whatever the “glob” pattern matches in the current directory, lists of files being separated by spaces. So that will simply lists all of the files that match * (basically all files that do not start with dot) in the current directory, then creates a huge string which each file name separated by spaces, then dumps that string to it’s output pipe.

    You are right about the pipe.

    The 2>&1 command is called a “redirect,” in this example it means to join the STDERR stream, which has integer code 2, to the STDOUT stream, which has integer code 1. This would make it so that error messages are also pushed to the input of the next process in the pipe, which usually you would not want to do unless you want a log of the result of the left side of the pipe. The 0> syntax indicates the STDIN stream (input stream, taken from the left of the pipeline) which can also be written as just <, the 1> syntax indicates STDOUT which can also be written as just >. You can also specify a file instead of a stream integer ID, so >text.csv says the STDOUT stream should write to a file rather than some other stream.

    The grep command searches it’s input stream for a “regular expression”, this is a very different kind of string pattern from the “glob expressions” (for example *.txt) that the shell uses. Regular expressions are more powerful than glob expressions. You can search Wikipedia for these terms, the articles there will give you a good sense of how each are used. Grep is also a line-based protocol, so it breaks it’s input into lines and only outputs the line if it matches the “regular expression”.

    The “grep” works on lines of text, and since echo creates only one line of text containing all the file names, grep will either print everything or nothing depending on whether the final file matched ends in “.txt“.

    In conversationabout a month ago from fe.disroot.orgpermalink
  • Help
  • About
  • FAQ
  • TOS
  • Privacy
  • Source
  • Version
  • Contact

GNU social JP is a social network, courtesy of GNU social JP管理人. It runs on GNU social, version 2.0.2-dev, available under the GNU Affero General Public License.

Creative Commons Attribution 3.0 All GNU social JP content and data are available under the Creative Commons Attribution 3.0 license.