Command q
Author: t | 2025-04-24
Command Description Example; q: Show available commands: q to show available commands: q shortcut_name optional_arguments Run shortcut: q search -q flow launcher to run
Q Command in Unix – Command Hunt
System commands13.1 Command Format¶Commands control aspects of the q run-time environment. A command begins with a backslash \ followed by the command name. Many commands have optional parameter(s) separated from the command name by a blank (multiple blanks or other whitespace characters are not permitted). Case is significant in the command name.Notes on optional parameters:Commands whose optional parameter sets an environmental value will display the current value when the parameter is omittedCommands whose parameter refers to a namespace apply to the current working context if the parameter is omitted.You could execute a command programmatically by placing it in a string as an argument to value. Observe that you must escape the \ in the string.q)value "**Error! Hyperlink reference not valid.**" / bad practice!Never do this in production – it exposes your system to all manner of attacks!Instead use the built-in system that at least checks for a valid command. Note that it also eliminates the backslash and hence the need to escape it.q)system "p 5042"13.1.1 List Tables \a¶The command \a [namespace], where namespace is an optional namespace, returns a sorted list of symbolic names of all tables in a context. When used without a parameter, it returns the tables in the current working context. For example, in a fresh q session,q)\a`symbol$()q)t:([] c1:`a`b`c; c2:10 20 30)q)\a,`tq).jab.t:([] c1:`a`b`c; c2:10 20 30)q)\a .jab,`t13.1.2 Views/Aliases \b¶The command \b [namespace] returns a sorted list of the symbolic names of the aliases (a.k.a. views, dependencies) in a context. In a fresh q session,q)\b`symbol$()q)a:42q)b::a+1q)c::b*bq)\b`s#`b`cSee §13.3.3 for the related .z.b.13.1.3 Pending Views/Aliases \B¶The command \B[namespace] (note upper case) returns a sorted list of the symbolic names of the aliases (a.k.a. views, dependencies) in a context that are stale – i.e., there is a pending update that will be realized on the next reference. In a fresh q session,q)x:42q)a::x+1q)\B,`aq)a43q)\B`symbol$()See. Command Description Example; q: Show available commands: q to show available commands: q shortcut_name optional_arguments Run shortcut: q search -q flow launcher to run A quick search for 'command q' on Google revealed these insights: have you ever accidentally hit ⌘Q and quit an app how to disable command-Q Command-Q is the worst keyboard The q or quit command. There is one more simple command that can restrict the changes to a set of lines. It is the q command: quit. the third way to duplicate the head command is: sed '11 q' Download Amazon Q for command line for macOS. Download Amazon Q for command line for AppImage (Linux) Download Amazon Q for command line for Ubuntu/Debian (Linux) For more information, see Using Amazon Q Developer on the command line. Amazon Q Developer in chat applications §13.3.3 for the related .z.b.13.1.4 Console \c¶The command \c [h w] displays (no arguments) or sets (pair of height and width as integers) the size of the virtual q console display. The default is 25 80i. In a fresh q session,q)\c25 80iq)\c 10 20q)2#enlist "abcdefghijkmlnopqrstuvwxyz""abcdefghijkmlnop.."abcdefghijkmlnop..13.1.5 Web Console \C¶The command \C [h w] (note upper case) displays (no arguments) or sets (pair of height and width as integers) the size of the virtual q console display for HTTP requests. The default is 25 80i. In a fresh q session, open port 5042 and point the browser to cut til 20The browser page will display,0 1 2 3 4 5 6 7 8 910 11 12 13 14 15 16 17 18 19Now issue the q command,q)\C 10 20and refresh the browser page. The page will now display,0 1 2 3 4 5 ..10 11 12 13 14 15 ..13.1.6 Change OS Directory \cd¶The \cd [path] command is passed directly through to the OS. To display the current directory, issue \cd with no argument.q)\cd"/Users/jeffry"To change the current working directory, issue \cd followed by the path of the desired directory. If the specified directory does not exist, q displays the error message from the OS.The \cd command creates the directory if it does not exist. For example, the directory /data is initially empty.q)\ls /dataq)\cd /data/newq)\ls /data"new"Windows users will know to write \dir \data and so on.13.1.7 Context \d¶The \d [namespace] command displays or changes the current context (a.k.a. directory in early versions of k). To determine the current context, issue \d with no parameter. In a fresh q session this will be the root. To change the current working context, include its namespace with the \d command. If the specified context does not exist, it will be created.q)\d`.q)\d .jabq.jab)\d .q)\d .jabq.jab)\d`.jabq.jab)\d .q)\d`.See ourComments
System commands13.1 Command Format¶Commands control aspects of the q run-time environment. A command begins with a backslash \ followed by the command name. Many commands have optional parameter(s) separated from the command name by a blank (multiple blanks or other whitespace characters are not permitted). Case is significant in the command name.Notes on optional parameters:Commands whose optional parameter sets an environmental value will display the current value when the parameter is omittedCommands whose parameter refers to a namespace apply to the current working context if the parameter is omitted.You could execute a command programmatically by placing it in a string as an argument to value. Observe that you must escape the \ in the string.q)value "**Error! Hyperlink reference not valid.**" / bad practice!Never do this in production – it exposes your system to all manner of attacks!Instead use the built-in system that at least checks for a valid command. Note that it also eliminates the backslash and hence the need to escape it.q)system "p 5042"13.1.1 List Tables \a¶The command \a [namespace], where namespace is an optional namespace, returns a sorted list of symbolic names of all tables in a context. When used without a parameter, it returns the tables in the current working context. For example, in a fresh q session,q)\a`symbol$()q)t:([] c1:`a`b`c; c2:10 20 30)q)\a,`tq).jab.t:([] c1:`a`b`c; c2:10 20 30)q)\a .jab,`t13.1.2 Views/Aliases \b¶The command \b [namespace] returns a sorted list of the symbolic names of the aliases (a.k.a. views, dependencies) in a context. In a fresh q session,q)\b`symbol$()q)a:42q)b::a+1q)c::b*bq)\b`s#`b`cSee §13.3.3 for the related .z.b.13.1.3 Pending Views/Aliases \B¶The command \B[namespace] (note upper case) returns a sorted list of the symbolic names of the aliases (a.k.a. views, dependencies) in a context that are stale – i.e., there is a pending update that will be realized on the next reference. In a fresh q session,q)x:42q)a::x+1q)\B,`aq)a43q)\B`symbol$()See
2025-04-23§13.3.3 for the related .z.b.13.1.4 Console \c¶The command \c [h w] displays (no arguments) or sets (pair of height and width as integers) the size of the virtual q console display. The default is 25 80i. In a fresh q session,q)\c25 80iq)\c 10 20q)2#enlist "abcdefghijkmlnopqrstuvwxyz""abcdefghijkmlnop.."abcdefghijkmlnop..13.1.5 Web Console \C¶The command \C [h w] (note upper case) displays (no arguments) or sets (pair of height and width as integers) the size of the virtual q console display for HTTP requests. The default is 25 80i. In a fresh q session, open port 5042 and point the browser to cut til 20The browser page will display,0 1 2 3 4 5 6 7 8 910 11 12 13 14 15 16 17 18 19Now issue the q command,q)\C 10 20and refresh the browser page. The page will now display,0 1 2 3 4 5 ..10 11 12 13 14 15 ..13.1.6 Change OS Directory \cd¶The \cd [path] command is passed directly through to the OS. To display the current directory, issue \cd with no argument.q)\cd"/Users/jeffry"To change the current working directory, issue \cd followed by the path of the desired directory. If the specified directory does not exist, q displays the error message from the OS.The \cd command creates the directory if it does not exist. For example, the directory /data is initially empty.q)\ls /dataq)\cd /data/newq)\ls /data"new"Windows users will know to write \dir \data and so on.13.1.7 Context \d¶The \d [namespace] command displays or changes the current context (a.k.a. directory in early versions of k). To determine the current context, issue \d with no parameter. In a fresh q session this will be the root. To change the current working context, include its namespace with the \d command. If the specified context does not exist, it will be created.q)\d`.q)\d .jabq.jab)\d .q)\d .jabq.jab)\d`.jabq.jab)\d .q)\d`.See our
2025-04-12Times an expression. It provides both the time and the number of bytes used in evaluating the expression.q)\ts log til 1000004 3145856You can also specify the number of repetitions, as with \t.q)\ts:100 log til 100000248 314582413.1.21 Timeout \T¶The \T secs command (note upper case) sets the number of seconds a remotely initiated execution will run before timing out. The default value is 0, meaning that such execution will not timeout. This is useful to protect against runaway client calls when the q process is acting as a server.See §13.2.15 for the related command line parameter -T.13.1.22 User Password \u¶When the q process has been started with the –u command to load a password file, the \u command reloads the password file. This allows the password to be changed while the process is running.See §13.2.17 for the related command line parameter -u.13.1.23 Variables \v¶The \v [namespace] command displays a sorted list of symbolic names of all variables in the specified context when the namespace parameter is present, or the current working context if it is not. In a fresh q session,q)\v`symbol$()q)a:b:c:42q)\v`a`b`cq)\v .`a`b`cq).jab.a:43q)\v .jab,`a13.1.24 Workspace \w¶The workspace command \w [0] displays information about resource utilization in the current q session. When the parameter is not present, it returns a list of six integers:Number of bytes allocatedNumber bytes available in heapMaximum heap size used heretofore in sessionMaximum bytes available as specified at startup in -wNumber of bytes for mapped entitiesNumber of bytes of physical (i.e. machine) memoryFor example, in a fresh q session on the author’s laptop:q)\w118256 67108864 67108864 0 0 17179869184q)bigdata:til 200000000q)\w2147601952 2214592512 2214592512 0 0 17179869184When the parameter is present, \w 0 returns a list with two items relating to symbol usage: the number of symbols and the corresponding number of bytes of memory used. For example, in a fresh q
2025-03-26And \2 allow you to redirect the OS stdout and stderr from within a q session. Follow the command with a file name for the redirected output. In a fresh q session,q)\1 /data/out.txtq)1+2*til 5q)\2 /data/err.txt6*`7\\>cat /data/out.txt1 3 5 7 9>cat /data/err.txtq)'type13.1.30 Operating System \text¶The command \oscmd, in which oscmd is any text not recognized as a q command, is assumed to be an operating system command and is passed to the OS for execution. Any output to stdout will be returned to q as strings. This is handy to avoid having to exit the q session and can be done programmatically with the system function. For example, on the author’s laptop,q)\pwd"/q4m"q)\ls /pages"c.js""sample0.html""sample1.html""sample2.html""ws101.html""ws101.q"q)pages:system "ls /pages"q)pages_TipIf oscmd results in an operating system error, an exception will be thrown in q. For safe programmatic execution, you can trap the exception by executing oscmd with system wrapped in protected evaluation.13.1.31 Interrupt (Ctl-c and Ctl-z)¶You can interrupt a long-running q function with Ctl-c. Note that some q functions are so tight that the interrupt may not be registered. You can terminate any q console session with extreme prejudice using Ctl-z, which will result in all contents of the workspace being lost.13.1.32 Terminate \¶Use \ to terminate one level of suspended execution arrived at via an exception.q)f:{x*y}q)f[2;`3]{x*y}'type*2`3q))\q)☐Do not have an itchy trigger finger when exiting multiple levels of suspended evaluation, as \\ will exit the q session immediately.If you are adventuresome, you can also issue \ at the normal q console prompt to toggle between the q interpreter and the k interpreter.q)\a:42-a-42\q)-a'-13.1.33 Exit \\¶To exit the q process, enter a double backslash \\ at any console prompt.q)\\$There is no confirmation prompt for \\. The q session is terminated with extreme prejudice.For programmatic q shutdown, use exit with a return value, which can be piped into other
2025-04-14