-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtype.txt
16 lines (12 loc) · 1 KB
/
type.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# Return what foo is, how it would be interpreted as command. For regular files use `file`.
$ type foo
# No flags return human-readable information: alias/function definition, 'x is a shell builtin/keyword', file location.# NB: aliases can override command paths, ie there can be multiple answers; type only shows the first by default.
-t only return string: alias, keyword, function, builtin, file. No match = no output, exit 1
-p/P interpret as file and return path
-P forces a PATH search (according to the man page, anyway) but only returns 1 match even with -a
-p returns all matches with -a but nothing when an alias overrides the command/script
-a return all matches
# pipe function output from `type` through `tail -n+2` to lose the first line and cat >> to a file or something (or pipe it to clipboard)
# NB, voice of experience: make sure you're not overwriting the file with just that function o.o;
# Also: you lose all comments in the function source
# See also: command, builtin, whereis