mirror of
https://gitea.com/mcereda/oam.git
synced 2026-02-08 21:34:25 +00:00
chore(kb): get the current shell
This commit is contained in:
40
knowledge base/get the current shell.md
Normal file
40
knowledge base/get the current shell.md
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
# Get the current shell
|
||||||
|
|
||||||
|
1. [TL;DR](#tldr)
|
||||||
|
1. [Further readings](#further-readings)
|
||||||
|
1. [Sources](#sources)
|
||||||
|
|
||||||
|
## TL;DR
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# Full path of the current shell's executable with arguments.
|
||||||
|
ps -o 'command='
|
||||||
|
|
||||||
|
# Full path of the current shell's executable only.
|
||||||
|
ps -o 'comm='
|
||||||
|
|
||||||
|
# Only the executable name.
|
||||||
|
ps -co 'comm='
|
||||||
|
|
||||||
|
# Unreliable: if the SHELL variable is set by a previous shell, that one is the
|
||||||
|
# value that will be shown.
|
||||||
|
echo "$SHELL"
|
||||||
|
echo "$0"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Further readings
|
||||||
|
|
||||||
|
### Sources
|
||||||
|
|
||||||
|
- [Remove the first line of a text file in Linux]
|
||||||
|
|
||||||
|
<!--
|
||||||
|
References
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!-- In-article sections -->
|
||||||
|
<!-- Knowledge base -->
|
||||||
|
<!-- Files -->
|
||||||
|
<!-- Upstream -->
|
||||||
|
<!-- Others -->
|
||||||
|
[remove the first line of a text file in linux]: https://www.baeldung.com/linux/remove-first-line-text-file
|
||||||
@@ -23,6 +23,9 @@ grep -R --exclude-dir 'excluded/dir' 'pattern' 'path/to/search/recursively' #
|
|||||||
# Show line numbers.
|
# Show line numbers.
|
||||||
grep -n 'pattern' 'path/to/search'
|
grep -n 'pattern' 'path/to/search'
|
||||||
|
|
||||||
|
# Only print the part matching the pattern.
|
||||||
|
ps | grep -o '/.*/fish' | head -n '1'
|
||||||
|
|
||||||
# Multiple parallel searches.
|
# Multiple parallel searches.
|
||||||
# Mind files with spaces in their name.
|
# Mind files with spaces in their name.
|
||||||
find . -type f | parallel -j +100% grep 'pattern'
|
find . -type f | parallel -j +100% grep 'pattern'
|
||||||
@@ -34,15 +37,15 @@ grep --color '[[:digit:]]' 'file.txt'
|
|||||||
|
|
||||||
## Variants
|
## Variants
|
||||||
|
|
||||||
- [`egrep`](#egrep) to use regular expressions in search patterns, same as `grep -E`
|
- `egrep` to use regular expressions in search patterns, same as `grep -E`
|
||||||
- [`fgrep`](#fgrep) to use patterns as fixed strings, same as `grep -F`
|
- `fgrep`] to use patterns as fixed strings, same as `grep -F`
|
||||||
- [archive-related variants](#archive-related-variants) for searching into compressed files
|
- [archive-related variants](#archive-related-variants) for searching into compressed files
|
||||||
- [`pdfgrep`](#pdfgrep) for searching into PDF files
|
- [`pdfgrep`](#pdfgrep) for searching into PDF files
|
||||||
|
|
||||||
### Archive-related variants
|
### Archive-related variants
|
||||||
|
|
||||||
- [`xzgrep`](#xzgrep) (with `xzegrep` and `xzfgrep`)
|
- `xzgrep` (with `xzegrep` and `xzfgrep`)
|
||||||
- [`zstdgrep`](#zstdgrep) for zstd archives
|
- `zstdgrep` for zstd archives
|
||||||
- many many others
|
- many many others
|
||||||
|
|
||||||
### PDFgrep
|
### PDFgrep
|
||||||
|
|||||||
Reference in New Issue
Block a user