Searching Commands:\n\n /pattern * Search forward for (N-th) matching line.\n ?pattern * Search backward for (N-th) matching line.\n n * Repeat previous search (for N-th occurrence).\n N * Repeat previous search in reverse direction.\n ESC-n * Repeat previous search, spanning files.\n ESC-N * Repeat previous search, reverse dir. & spanning files.\n ESC-u Undo (toggle) search highlighting.\n ---------------------------------------------------\n Search patterns can be modified by one or more of:\n ^N or ! Search for NON-matching lines.\n ^E or * Search multiple files (pass thru END OF FILE).\n ^F or @ Start search at FIRST file (for /) or last file (for ?).\n ^K Highlight matches, but don't move (KEEP position).\n ^R Don't use REGULAR EXPRESSIONS.\n\n[[next|less three]]
You stare blankly at the terminal on your girlfriend's spare laptop. She's left you written notes - well, typed notes, of course, with a handwritten scrawl across the top:\n\n''This should keep you busy while I'm away! \nxx''\n\nand her signature beneath that. \n\nYou know she's pretentious about computers, and you love her for that too, but you're not sure why you're doing this for her. I mean, you're probably going to break her laptop. Even if she's painstakingly printed out instructions on how to use the command line. \n\nYou sigh, and begin to read. \n\n[[ls|ls one]]
less: Display output one screen at a time, Search through output, Edit the command line.\n\nIt looks like there's a way to print a file in a way that you can search through it, even if the searching is arcane. \n\nless .passwords\n\nThen, once the first screen pops up, you go through it with page up and page down. It's not really working, there has to be a better way. You thought there was something about searching. \n\n[[man|man one]]\n<<if $man eq true>>\n[[man less|less two]]\n<<endif>>
grep: Search files for specific text. \n\nAfter consulting your papers, you type:\n\ngrep "dont" .passwords\n\nThe line with that filename, and the password, comes up. \n\nYou write it down on a piece of paper, and alt-tab back to LibreOffice, where you type out the [[password]].
Syntax\n man [-acdfFhkKtwW] [--path] [-m system] [-p string] [-C config_file]\n [-M pathlist] [-P pager] [-B browser] [-H htmlpager] [-S section_list]\n [section] name ... \n\nKey:\n\n -C config_file The configuration file to use; the default is /etc/man.config. (See man.config(5).) \n\n -M path The list of directories to search for man pages. Separate the directories with colons.\n An empty list is the same as not specifying -M at all. See SEARCH PATH FOR MANUAL PAGES. \n\n -P pager Which pager to use. This option overrides the MANPAGER environment variable, which in turn\n overrides the PAGER variable. By default, man uses /usr/bin/less -is. \n\n -B Which browser to use on HTML files. This option overrides the BROWSER environment variable.\n By default, man uses /usr/bin/less-is,\n\n -H Specify a command that renders HTML files as text. This option overrides the HTMLPAGER environment variable.\n By default, man uses /bin/cat,\n\n -S section_list List is a colon separated list of manual sections to search. This option overrides the MANSECT environment variable.\n\n -a By default, man will exit after displaying the first manual page it finds.\n Using this option forces man to display all the manual pages that match name, not just the first.\n\n -c Reformat the source man page, even when an up-to-date cat page exists.\n This can be meaningful if the cat page was formatted for a screen with a different number of columns,\n or if the preformatted page is corrupted.\n\n -d Don't actually display the man pages, but do print gobs of debugging information.\n\n -D Both display and print debugging info.\n\n -f Equivalent to whatis.\n\n -F\n --preformat Format only - do not display. \n\n -h Print a help message and exit.\n\n -k Equivalent to apropos.\n\n -K Search for the specified string in *all* man pages.\n Warning: this can be very slow and can match multiple pages! It helps to specify a section.\n\n -m system Specify an alternate set of man pages to search based on the system name given.\n\n -p string Specify the sequence of preprocessors to run before nroff or troff.\n Not all installations will have a full set of preprocessors.\n Some of the preprocessors and the letters used to designate\n them: eqn (e), grap (g), pic (p), tbl (t), vgrind (v), refer (r).\n This option overrides the MANROFFSEQ environment variable.\n\n -t Use /usr/bin/groff -Tps -mandoc to format the manual page, passing the output to stdout.\n The default output format of /usr/bin/groff -Tps -mandoc is Postscript, refer to the\n manual page of /usr/bin/groff -Tps -mandoc for ways to pick an alternate format.\n Depending on the selected format and the availability of printing devices, the output may\n need to be passed through some filter or another before being printed.\n\n -w\n --path Don't actually display the man pages, but do print the location(s) of the files that\n would be formatted or displayed. If no argument is given: display (on stdout) the list\n of directories that is searched by man for man pages. If manpath is a link to man, then\n "manpath" is equivalent to "man --path". \n\n -W Like -w, but print file names one per line, without additional information.\n This is useful in shell commands like man -aW man | xargs ls -l \n\nPress <Space bar> to view the next page\nPress <return> to view next line\nPress <ctrl-C> to exit\n\nMan displays help pages. If you specify section, man only looks in that section of the manual. name is normally the name of the manual page, which is typically the name of a command, function, or file. However, if name contains a slash (/) then man interprets it as a file specification, so that you can do man ./foo.5 or even man /cd/foo/bar.1.gz. See below for a description of where man looks for the manual page files.\nInternal commands\n\nFor simplicity, the SS64 website includes both internal GNU bash commands and external unix commands in a single list. Many more commands are available and the man command will list the full details of these.\n\nInternal means a command built into the shell, it's the shell that performs the action.\nExternal means the shell will fork and execute an external program as a new subprocess. External commands are available when running any shell.\n\nFor example, the cd command is built-in. The ls command, is external.\n\nThe man command lists all the internal commands for bash under man bash\nSearch Path for Manual Pages\n\nman uses a sophisticated method of finding manual page files, based on the invocation options and environment variables, the /etc/man.config configuration file, and some built in conventions and heuristics.\n\nFirst, when the name argument to man contains a slash (/), man assumes it is a file specification itself, and there is no searching involved.\n\nBut in the normal case where name doesn't contain a slash, man searches a variety of directories for a file that could be a manual page for the topic named.\n\nIf you specify the -M pathlist option, pathlist is a colon-separated list of the directories that man searches.\n\nIf you don't specify --M but set the MANPATH environment variable, the value of that variable is the list of the directories that man searches.\n\nIf you don't specify an explicit path list with -M or MANPATH, man develops its own path list based on the contents of the configuration file /etc/man.config. The MANPATH statements in the configuration file identify particular directories to include in the search path.\n\nFurthermore, the MANPATH_MAP statements add to the search path depending on your command search path (i.e. your PATH environment variable). For each directory that may be in the command search path, a MANPATH_MAP statement specifies a directory that should be added to the search path for manual page files. man looks at the PATH variable and adds the corresponding directories to the manual page file search path. Thus, with the proper use of MANPATH_MAP, when you issue the command man xyz, you get a manual page for the program that would run if you issued the command xyz.\n\nIn addition, for each directory in the command search path (we'll call it a "command directory") for which you do not have a MANPATH_MAP statement, man automatically looks for a manual page directory "nearby" namely as a subdirectory in the command directory itself or in the parent directory of the command directory.\n\nYou can disable the automatic "nearby" searches by including a NOAUTOPATH statement in /etc/man.config.\n\nIn each directory in the search path as described above, man searches for a file named topic.section, with an optional suffix on the section number and possibly a compression suffix. If it doesn't find such a file, it then looks in any subdirectories named manN or catN where N is the manual section number. If the file is in a catN subdirectory, man assumes it is a formatted manual page file (cat page). Otherwise, man assumes it is unformatted. In either case, if the filename has a known compression suffix (like .gz), man assumes it is gzipped.\n\nIf you want to see where (or if) man would find the manual page for a particular topic, use the --path (-w) option.\nEnvironment\n\nMANPATH If MANPATH is set, man uses it as the path to search for manual page files.\n It overrides the configuration file and the automatic search path, but is overridden by the -M invocation option.\n See SEARCH PATH FOR MANUAL PAGES. \nMANPL If MANPL is set, its value is used as the display page length. Otherwise, the entire man page will occupy one (long) page.\nMANROFFSEQ If MANROFFSEQ is set, its value is used to determine the set of preprocessors run before running nroff or troff.\n By default, pages are passed through the tbl preprocessor before nroff. \nMANSECT If MANSECT is set, its value is used to determine which manual sections to search. \nMANWIDTH If MANWIDTH is set, its value is used as the width manpages should be displayed.\n Otherwise the pages can be displayed over the whole width of your screen. \nMANPAGER If MANPAGER is set, its value is used as the name of the program to use to display the man page.\n If not, then PAGER is used. If that has no value either, /usr/bin/less -is is used. \nBROWSER The name of a browser to use for displaying HTML manual pages. If it is not set, /usr/bin/less -is is used. \nHTMLPAGER The command to use for rendering HTML manual pages as text. If it is not set, /bin/cat is used. \nLANG If LANG is set, its value defines the name of the subdirectory where man first looks for man pages.\n Thus, the command 'LANG=dk man 1 foo' will cause man to look for the foo man page in .../dk/man1/foo.1,\n and if it cannot find such a file, then in .../man1/foo.1, where ... is a directory on the search path.\nNLSPATH, LC_MESSAGES, LANG\n The environment variables NLSPATH and LC_MESSAGES (or LANG when the latter does not exist) play a role in\n locating the message catalog. (But the English messages are compiled in, and for English no catalog is\n required.) Note that programs like col(1) called by man also use e.g. LC_CTYPE. \nPATH PATH helps determine the search path for manual page files. See SEARCH PATH FOR MANUAL PAGES.\nSYSTEM SYSTEM is used to get the default alternate system name (for use with the -m option).\n\nBugs\n\nThe -t option only works if a troff-like program is installed.\nIf you see blinking \s255 or instead of hyphens, put 'LESSCHARSET=latin1' in your environment.\n\nExamples\n\n$ man intro\n\n$ man 1 rsync\n\n$ man rsync\n\nIf you add the line (global-set-key [(f1)] (lambda () (interactive) (manual-entry (current-word)))) to your .emacs file, then hitting F1 will give you the man page for the library call at the current cursor position.\n\nTo get a plain text version of a man page, without backspaces and underscores, try:\n\n$ man foo | col -b > foo.mantxt \n\n[[back|less one]]\n\n<<set $man = true>>
The file prompts you for a password. \n\nIf you could open the ".passwords" file, maybe you could get in. But it doesn't have the right extension to open here? \n\n[[cat|cat one]]
ls: List information about files. \n\nHesitantly, you press the two keys, and then hit enter. You see a list of, presumably, files and directories. \n\nThere's the usual - Documents, Downloads, Music, and so on - but there's also something which catches your eye. You know you shouldn't read a file titled "dont read this.odt", but... maybe it's no longer relevant? \n\nYou thought she hadn't used this computer in a while. Maybe there's some way you could check? \n\n[[ls -la|ls two]]
cat: Concatenate and print the contents of files.\n\nThis looks promising. \n\ncat .passwords, you type, and hit enter. \n\nYou've hit the jackpot. A list of names and corresponding passwords begins to scroll. It keeps going for longer than you expected, though. And by the time you reach the end, nothing for "dont read this.odt" is visible anymore. If only you could search through it!\n\n[[grep|grep one]]\n[[less|less one]]
You search for "dont", and find the password, and write it down on a piece of paper you have handy. Your girlfriend is probably laughing at you right now from her trip, and she doesn't know why. Then again, she probably won't be laughing when you read this file. \n\nYou remember: Curiosity killed the cat, but satisfaction brought it back.\n\nYou type 'q' to exit less. You learned that trick from the man page. \n\nYou alt-tab back to LibreOffice, and [[type in the password|password]].
me, in response to tane.us/nintendo/\n''super excited for christine love's new game "Wii Permission U"''\n\nTo Christine Love: You inspire me. I'm sorry, you deserve better than inspiring me to make trash like this. \n\n[[begin]]\n<<set $man = false>>
The file loads in the editor. You feel like a real hacker. \n\nYou start to read it.\n\n''I touch her, and she shudders. I wish she would let me do more. I want her to beg me''\n\nThis seems familiar, but you're sure you've never read it before. You realize that you were there for it, shuddering under your girlfriend's touch. \n\nYou're not sure you should be reading this. You can't look away. \n\nYou're starting to feel [[warm]], and you don't think it's because of the weather.
''She moans my name, and then 'please'. I reach towards her''\n\nYou definitely remember this.\n\nYou read the rest of the file. Luckily LibreOffice has a GUI, so you can use the scroll wheel with only one hand. \n\nWhen you reach the end, there's only a little bit of the file left. You keep reading, even though it doesn't seem as urgent anymore. \n\n''i love you, and i can't wait to get back from my trip so we can do this again. i hope you had fun learning about linux command line utilities! \nxx''\n\nYou roll your eyes - of course she would - and go to clean up.
fsck me harder: an educational *nix parable
@precisememory
man: Manual info. Format and display help pages.\n\nYou're not sure this will work, but what the hell.\n\n[[man man|man two]]
The -l option of ls lists information about the files. The -a option of ls lists all files, including hidden ones.\n\nMaybe you were wrong that she hadn't used it in a while. \n\nThe thing that caught your eye, the file you shouldn't read (according to its name), is from last week. You also notice something new, a hidden file from the same time, give or take a few minutes. The hidden file didn't show up last time because its name was prefixed with a '.'. It's called ".passwords", which seems pretty insecure to you, but what do you know? You're not the computer expert in the house. \n\nLuckily, though she left the terminal helpfully fullscreened for you, she said you could alt-tab to find the same instructions open in LibreOffice. So you alt-tab over there, but against the angels of your better nature, you [[go to File > Open... |ls three]]\n