{
    "content": [
        {
            "type": "text",
            "text": "# strfile(1) (man)\n\n**Summary:** strfile - create a random access file for storing strings unstr - dump strings in pointer order\n\n**Synopsis:** strfile [-iorsx] [-c char] sourcefile [outputfile]\nunstr [-c char] datafile[.ext] [outputfile]\n\n## Flags\n\n| Flag | Long | Arg | Description |\n|------|------|-----|-------------|\n| -c | — | — | Change the delimiting character from the percent sign to char. This option is avail‐ able for both strfile and unstr. |\n| -i | — | — |  |\n| -o | — | — | phabetical order of the groups of lines referenced. Any initial non-alphanumeric characters are ignored. This option cau |\n| -r | — | — | dered. This option causes the STRRANDOM bit in the header strflags field to be set. (And really does randomize) |\n| -s | — | — |  |\n| -x | — | — | a simple caesar cypher. This option causes the STRROTATED bit in the header strflags field to be set. Note that it does  |\n\n## See Also\n\n- byteorder(3)\n- fortune(6)\n\n## Section Outline\n\n- **NAME** (3 lines)\n- **SYNOPSIS** (3 lines)\n- **DESCRIPTION** (16 lines) — 8 subsections\n  - Options (2 lines)\n  - -c (3 lines)\n  - -i (1 lines)\n  - -o (4 lines)\n  - -r (3 lines)\n  - -s (1 lines)\n  - -x (4 lines)\n  - Header (15 lines)\n- **BUGS** (4 lines)\n- **OTHER USES** (23 lines)\n- **SEE ALSO** (2 lines)\n- **HISTORY** (8 lines)\n\n## Full Content\n\n### NAME\n\nstrfile - create a random access file for storing strings\nunstr - dump strings in pointer order\n\n### SYNOPSIS\n\nstrfile [-iorsx] [-c char] sourcefile [outputfile]\nunstr [-c char] datafile[.ext] [outputfile]\n\n### DESCRIPTION\n\nstrfile  reads a file containing groups of lines separated by a line containing a single per‐\ncent `%' sign (or other specified delimiter character) and creates a data file which contains\na  header  structure  and a table of file offsets for each group of lines. This allows random\naccess of the strings.\n\nThe output file, if not specified on the command line, is named sourcefile.dat.\n\nThe purpose of unstr is to undo the work of strfile.  It prints out the strings contained  in\nthe  sourcefile,  which is datafile.ext without its extension, or datafile if no extension is\nspecified (in this case, the extension .dat is added to the name of the datafile) in the  or‐\nder  that  they  are  listed  in the header file datafile.  If no outputfile is specified, it\nprints to standard output; otherwise it prints to the file specified.  unstr can also univer‐\nsally change the delimiter character in a strings file.  It is possible to create sorted ver‐\nsions of input files by using strfile -o and then using unstr to dump them out in  the  table\norder.\n\n#### Options\n\nThe options are as follows:\n\n#### -c\n\nChange  the delimiting character from the percent sign to char.  This option is avail‐\nable for both strfile and unstr.\n\n#### -i\n\n#### -o\n\nphabetical  order  of  the  groups  of lines referenced.  Any initial non-alphanumeric\ncharacters are ignored. This option causes the STRORDERED bit in the header strflags\nfield to be set. (It also now really does sort! It didn't used to).\n\n#### -r\n\ndered.  This option causes the STRRANDOM bit in the header strflags field to be set.\n(And really does randomize)\n\n#### -s\n\n#### -x\n\na simple caesar cypher.   This  option  causes  the  STRROTATED  bit  in  the  header\nstrflags  field  to  be set. Note that it does not rotate the strings--that operation\nmust be performed separately.\n\n#### Header\n\nThe format of the header is:\n\n#define VERSION 1\nunsigned long strversion;  /* version number */\nunsigned long strnumstr;   /* # of strings in the file */\nunsigned long strlonglen;  /* length of longest string */\nunsigned long strshortlen; /* shortest string length */\n#define STRRANDOM    0x1   /* randomized pointers */\n#define STRORDERED   0x2   /* ordered pointers */\n#define STRROTATED   0x4   /* rot-13'd text */\nunsigned long strflags;    /* bit field for flags */\nchar strdelim;             /* delimiting character */\n\nAll fields are written in network byte order.\n\n### BUGS\n\nFewer now, one hopes.  However, fortunes (text strings) beginning with a blank line appear to\nbe  sorted  between  random  letters.   This includes ASCII art that contains no letters, and\nfirst lines that are solely non-alphanumeric, apparently.  I've no idea why this should be.\n\n### OTHER USES\n\nWhat can you do with this besides printing sarcastic and obscene messages to the  screens  of\nlusers at login or logout?\n\nThere  are  some other possibilities.  Source code for a sample program, randstr, is included\nwith this distribution: randstr splits the difference between unstr and fortune.  It reads  a\nsingle, specified file, and randomly selects a single text string.\n\n1      Include  strfile.h into a news reading/posting program, to generate random signatures.\nTin(1) does something similar, in a much more complex manner.\n\n2      Include it in a game.  While strfile doesn't support 'fields' or 'records', there's no\nreason that the text strings can't be consistent: first line, a die roll; second line,\na score; third and subsequent lines, a text message.\n\n3      Use it to store your address book.  Hell, some of the guys I know would be as well off\nusing  it  to  decide  who  to call on Friday nights (and for some, it wouldn't matter\nwhether there were phone numbers in it or not).\n\n4      Use it in 'lottery' situations.  If you're an ISP, write a script to store login names\nand  GECOS from /etc/passwd in strfile format, write another to send 'congratulations,\nyou've won' to the lucky login selected.  The prize might be a month's  free  service,\nor if you're AOL, a month free on a real service provider.\n\n### SEE ALSO\n\nbyteorder(3), fortune(6)\n\n### HISTORY\n\nThe  strfile  utility first appeared in 4.4BSD. This version was heavily modified, much of it\nin ways peculiar to Linux.  Work has since been done to make the code more generic,  and  has\nso  far  been  tested to work with SunOS 4.x.  More platforms are expected to be supported as\nwork continues.\n\n\n\n4th Berkeley Distribution              June 9, 1993 [Apr. '97]                            STRFILE(1)\n\n"
        }
    ],
    "structuredContent": {
        "command": "strfile",
        "section": "1",
        "mode": "man",
        "summary": "strfile - create a random access file for storing strings unstr - dump strings in pointer order",
        "synopsis": "strfile [-iorsx] [-c char] sourcefile [outputfile]\nunstr [-c char] datafile[.ext] [outputfile]",
        "flags": [
            {
                "flag": "-c",
                "long": null,
                "arg": null,
                "description": "Change the delimiting character from the percent sign to char. This option is avail‐ able for both strfile and unstr."
            },
            {
                "flag": "-i",
                "long": null,
                "arg": null,
                "description": ""
            },
            {
                "flag": "-o",
                "long": null,
                "arg": null,
                "description": "phabetical order of the groups of lines referenced. Any initial non-alphanumeric characters are ignored. This option causes the STRORDERED bit in the header strflags field to be set. (It also now really does sort! It didn't used to)."
            },
            {
                "flag": "-r",
                "long": null,
                "arg": null,
                "description": "dered. This option causes the STRRANDOM bit in the header strflags field to be set. (And really does randomize)"
            },
            {
                "flag": "-s",
                "long": null,
                "arg": null,
                "description": ""
            },
            {
                "flag": "-x",
                "long": null,
                "arg": null,
                "description": "a simple caesar cypher. This option causes the STRROTATED bit in the header strflags field to be set. Note that it does not rotate the strings--that operation must be performed separately."
            }
        ],
        "examples": [],
        "see_also": [
            {
                "name": "byteorder",
                "section": "3",
                "url": "https://www.chedong.com/phpMan.php/man/byteorder/3/json"
            },
            {
                "name": "fortune",
                "section": "6",
                "url": "https://www.chedong.com/phpMan.php/man/fortune/6/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 16,
                "subsections": [
                    {
                        "name": "Options",
                        "lines": 2
                    },
                    {
                        "name": "-c",
                        "lines": 3,
                        "flag": "-c"
                    },
                    {
                        "name": "-i",
                        "lines": 1,
                        "flag": "-i"
                    },
                    {
                        "name": "-o",
                        "lines": 4,
                        "flag": "-o"
                    },
                    {
                        "name": "-r",
                        "lines": 3,
                        "flag": "-r"
                    },
                    {
                        "name": "-s",
                        "lines": 1,
                        "flag": "-s"
                    },
                    {
                        "name": "-x",
                        "lines": 4,
                        "flag": "-x"
                    },
                    {
                        "name": "Header",
                        "lines": 15
                    }
                ]
            },
            {
                "name": "BUGS",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "OTHER USES",
                "lines": 23,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "HISTORY",
                "lines": 8,
                "subsections": []
            }
        ]
    }
}