aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/awk.html22
-rw-r--r--tools/bash.html47
-rw-r--r--tools/dot.html4
-rw-r--r--tools/ffmpeg.html4
-rw-r--r--tools/fish.html34
-rw-r--r--tools/gdb.html2
-rw-r--r--tools/git.html2
-rw-r--r--tools/gnuplot.html40
-rw-r--r--tools/pacman.html2
-rw-r--r--tools/qemu.html8
-rw-r--r--tools/radare2.html2
-rw-r--r--tools/sed.html22
-rw-r--r--tools/tmux.html2
-rw-r--r--tools/zsh.html38
14 files changed, 134 insertions, 95 deletions
diff --git a/tools/awk.html b/tools/awk.html
index 9d301da..bdf80b2 100644
--- a/tools/awk.html
+++ b/tools/awk.html
@@ -238,7 +238,7 @@ multiple times. Actions with those patterns are <strong>executed exactly once</s
<h3 id="special-statements--functions"><a class="header" href="#special-statements--functions">Special statements &amp; functions</a></h3>
<ul>
<li>
-<p><code>printf &quot;fmt&quot;, args...</code></p>
+<p><code>printf "fmt", args...</code></p>
<p>Print format string, args are comma separated.</p>
<ul>
<li><code>%s</code> string</li>
@@ -251,12 +251,12 @@ For floats one can use <code>%N.Mf</code>, <code>N</code> is the total number in
<code>M</code>.</p>
</li>
<li>
-<p><code>sprintf(&quot;fmt&quot;, expr, ...)</code></p>
+<p><code>sprintf("fmt", expr, ...)</code></p>
<p>Format the expressions according to the format string. Similar as <code>printf</code>,
but this is a function and return value can be assigned to a variable.</p>
</li>
<li>
-<p><code>strftime(&quot;fmt&quot;)</code></p>
+<p><code>strftime("fmt")</code></p>
<p>Print time stamp formatted by <code>fmt</code>.</p>
<ul>
<li><code>%Y</code> full year (eg 2020)</li>
@@ -290,7 +290,7 @@ prints the whole record.</p>
</code></pre>
<p>Matches records not starting with <code>#</code>.</p>
<h3 id="range-patterns"><a class="header" href="#range-patterns">Range patterns</a></h3>
-<pre><code class="language-bash">echo -e &quot;a\nFOO\nb\nc\nBAR\nd&quot; | \
+<pre><code class="language-bash">echo -e "a\nFOO\nb\nc\nBAR\nd" | \
awk '/FOO/,/BAR/ { print }'
</code></pre>
<p><code>/FOO/,/BAR/</code> define a range pattern of <code>begin_pattern, end_pattern</code>. When
@@ -298,13 +298,17 @@ prints the whole record.</p>
<code>end_pattern</code> is matched the range is <strong>turned off</strong>. This matches every record
in the range <em>inclusive</em>.</p>
<p>An <em>exclusive</em> range must be handled explicitly, for example as follows.</p>
-<pre><code class="language-bash">echo -e &quot;a\nFOO\nb\nc\nBAR\nd&quot; | \
- awk '/FOO/,/BAR/ { if (!($1 ~ &quot;FOO&quot;) &amp;&amp; !($1 ~ &quot;BAR&quot;)) { print } }'
+<pre><code class="language-bash">echo -e "a\nFOO\nb\nc\nBAR\nd" | \
+ awk '/FOO/,/BAR/ { if (!($1 ~ "FOO") &amp;&amp; !($1 ~ "BAR")) { print } }'
</code></pre>
<h3 id="access-last-fields-in-records"><a class="header" href="#access-last-fields-in-records">Access last fields in records</a></h3>
<pre><code class="language-bash">echo 'a b c d e f' | awk '{ print $NF $(NF-1) }'
</code></pre>
<p>Access last fields with arithmetic on the <code>NF</code> number of fields variable.</p>
+<h3 id="split-on-multiple-tokens"><a class="header" href="#split-on-multiple-tokens">Split on multiple tokens</a></h3>
+<pre><code class="language-bash">echo 'a,b;c:d' | awk -F'[,;:]' '{ printf "1=%s | 4=%s\n", $1, $4 }'
+</code></pre>
+<p>Use regex as field separator.</p>
<h3 id="capture-in-variables"><a class="header" href="#capture-in-variables">Capture in variables</a></h3>
<pre><code class="language-bash"># /proc/&lt;pid&gt;/status
# Name: cat
@@ -316,7 +320,7 @@ for f in /proc/*/status; do
cat $f | awk '
/^VmRSS/ { rss = $2/1024 }
/^Name/ { name = $2 }
- END { printf &quot;%16s %6d MB\n&quot;, name, rss }';
+ END { printf "%16s %6d MB\n", name, rss }';
done | sort -k2 -n
</code></pre>
<p>We capture values from <code>VmRSS</code> and <code>Name</code> into variables and print them at the
@@ -331,7 +335,7 @@ a 1' | awk '{
}
END {
for (v in vals)
- printf &quot;%s %d\n&quot;, v, vals[v] / cnts [v]
+ printf "%s %d\n", v, vals[v] / cnts [v]
}'
</code></pre>
<p>Capture keys and values from different columns and some up the values.
@@ -339,7 +343,7 @@ At the <code>END</code> we compute the average of each key.</p>
<h3 id="run-shell-command-and-capture-output"><a class="header" href="#run-shell-command-and-capture-output">Run shell command and capture output</a></h3>
<pre><code class="language-bash">cat /proc/1/status | awk '
/^Pid/ {
- &quot;ps --no-header -o user &quot; $2 | getline user;
+ "ps --no-header -o user " $2 | getline user;
print user
}'
</code></pre>
diff --git a/tools/bash.html b/tools/bash.html
index 580e941..91d44cb 100644
--- a/tools/bash.html
+++ b/tools/bash.html
@@ -192,7 +192,7 @@
bar=${foo:-some_val} # if $foo set, then bar=$foo else bar=some_val
# alternate value
-bar=${foo:+bla $foo} # if $foo set, then bar=&quot;bla $foo&quot; else bar=&quot;&quot;
+bar=${foo:+bla $foo} # if $foo set, then bar="bla $foo" else bar=""
# check param set
bar=${foo:?msg} # if $foo set, then bar=$foo else exit and print msg
@@ -274,6 +274,19 @@ contains some nice visualization to explain bash redirections.</p>
once.</p>
<pre><code class="language-bash">vim -d &lt;(grep foo bar) &lt;(grep foo moose)
</code></pre>
+<h2 id="command-grouping"><a class="header" href="#command-grouping">Command grouping</a></h2>
+<p>Execute commands in a group with or without subshell. Can be used to easily
+redirect stdout/stderr of all commands in the group into one file.</p>
+<pre><code class="language-bash"># Group commands without subshell.
+v=abc ; { v=foo; echo $v; } ; echo $v
+# foo
+# foo
+
+# Group commands with subshell.
+v=abc ; ( v=foo; echo $v; ) ; echo $v
+# foo
+# abc
+</code></pre>
<h2 id="argument-parsing-with-getopts"><a class="header" href="#argument-parsing-with-getopts">Argument parsing with <code>getopts</code></a></h2>
<p>The <code>getopts</code> builtin uses following global variables:</p>
<ul>
@@ -296,11 +309,11 @@ once.</p>
<h3 id="example"><a class="header" href="#example">Example</a></h3>
<pre><code class="language-bash">#!/bin/bash
function parse_args() {
- while getopts &quot;f:c&quot; PARAM; do
+ while getopts "f:c" PARAM; do
case $PARAM in
- f) echo &quot;GOT -f $OPTARG&quot;;;
- c) echo &quot;GOT -c&quot;;;
- *) echo &quot;ERR: print usage&quot;; exit 1;;
+ f) echo "GOT -f $OPTARG";;
+ c) echo "GOT -c";;
+ *) echo "ERR: print usage"; exit 1;;
esac
done
# users responsibility to reset OPTIND
@@ -320,14 +333,14 @@ The match results can be accessed via the <code>$BASH_REMATCH</code> variable:</
<pre><code class="language-bash">INPUT='title foo : 1234'
REGEX='^title (.+) : ([0-9]+)$'
if [[ $INPUT =~ $REGEX ]]; then
- echo &quot;${BASH_REMATCH[0]}&quot; # title foo : 1234
- echo &quot;${BASH_REMATCH[1]}&quot; # foo
- echo &quot;${BASH_REMATCH[2]}&quot; # 1234
+ echo "${BASH_REMATCH[0]}" # title foo : 1234
+ echo "${BASH_REMATCH[1]}" # foo
+ echo "${BASH_REMATCH[2]}" # 1234
fi
</code></pre>
<blockquote>
<p><strong>Caution</strong>: When specifying a <code>regex</code> in the <code>[[ ]]</code> block directly, quotes will be treated as part of the pattern.
-<code>[[ $INPUT =~ &quot;foo&quot; ]]</code> will match against <code>&quot;foo&quot;</code> not <code>foo</code>!</p>
+<code>[[ $INPUT =~ "foo" ]]</code> will match against <code>"foo"</code> not <code>foo</code>!</p>
</blockquote>
<h2 id="completion"><a class="header" href="#completion">Completion</a></h2>
<p>The <code>complete</code> builtin is used to interact with the completion system.</p>
@@ -358,11 +371,11 @@ against words generated by <code>option</code>.</p>
# -u generate list with users
# -e generate list with exported variables
-# compare &quot;f&quot; against words &quot;foo&quot; &quot;foobar&quot; &quot;bar&quot; and generate matches
-compgen -W &quot;foo foobar bar&quot; &quot;f&quot;
+# compare "f" against words "foo" "foobar" "bar" and generate matches
+compgen -W "foo foobar bar" "f"
-# compare &quot;hom&quot; against file/dir names and generate matches
-compgen -d -f &quot;hom&quot;
+# compare "hom" against file/dir names and generate matches
+compgen -d -f "hom"
</code></pre>
<h3 id="example-1"><a class="header" href="#example-1">Example</a></h3>
<p>Skeleton to copy/paste for writing simple completions.</p>
@@ -374,12 +387,12 @@ compgen -d -f &quot;hom&quot;
local curr=$2
local prev=$3
- local opts=&quot;-c -s -f -h&quot;
+ local opts="-c -s -f -h"
case $prev in
- -c) COMPREPLY=( $(compgen -W &quot;green red blue&quot; -- $curr) );;
- -s) COMPREPLY=( $(compgen -W &quot;low high&quot; -- $curr) );;
+ -c) COMPREPLY=( $(compgen -W "green red blue" -- $curr) );;
+ -s) COMPREPLY=( $(compgen -W "low high" -- $curr) );;
-f) COMPREPLY=( $(compgen -f -- $curr) );;
- *) COMPREPLY=( $(compgen -W &quot;$opts&quot; -- $curr) );;
+ *) COMPREPLY=( $(compgen -W "$opts" -- $curr) );;
esac
}
diff --git a/tools/dot.html b/tools/dot.html
index 5e45abd..60a5c39 100644
--- a/tools/dot.html
+++ b/tools/dot.html
@@ -200,10 +200,10 @@ digraph {
// Add multiple edges at once.
stage2 -&gt; { stage3_1, stage3_2 }
// Add edge with custom attributes.
- stage3_2 -&gt; stage4 [label=&quot;some text&quot;]
+ stage3_2 -&gt; stage4 [label="some text"]
// Set custom attributes for specific node.
- stage4 [color=green,fillcolor=lightgray,style=&quot;filled,dashed&quot;,label=&quot;s4&quot;]
+ stage4 [color=green,fillcolor=lightgray,style="filled,dashed",label="s4"]
// Create a subgraph. This can be used to group nodes/edges or as scope for
// global node/edge attributes.
diff --git a/tools/ffmpeg.html b/tools/ffmpeg.html
index 3c8a3f1..563a011 100644
--- a/tools/ffmpeg.html
+++ b/tools/ffmpeg.html
@@ -181,14 +181,14 @@
<p>Following snippet allows to select a window which is then captured.</p>
<pre><code class="language-bash">#!/bin/bash
-echo &quot;Click on window to record ..&quot;
+echo "Click on window to record .."
# Extract window size and x,y offset.
video_args=$(xwininfo \
| awk '/Absolute upper-left X:/ { xoff = $4 }
/Absolute upper-left Y:/ { yoff=$4 }
/Width:/ { if ($2 % 2 == 1) { width=$2-1; } else { width=$2; } }
/Height:/ { if ($2 % 2 == 1) { height=$2-1; } else { height=$2; } }
- END { printf &quot;-video_size %dx%d -i :0.0+%d,%d&quot;, width, height, xoff, yoff }')
+ END { printf "-video_size %dx%d -i :0.0+%d,%d", width, height, xoff, yoff }')
ffmpeg -framerate 25 -f x11grab $video_args -pix_fmt yuv420p $@ output.mp4
</code></pre>
diff --git a/tools/fish.html b/tools/fish.html
index 34faca9..26c920c 100644
--- a/tools/fish.html
+++ b/tools/fish.html
@@ -237,16 +237,16 @@ echo {a,b}{1,2}
with <code>:</code> when quoted or exported to the environment.</p>
<pre><code class="language-sh">set -x BLA_PATH a:b:c:d
echo $BLA_PATH # a b c d
-echo &quot;$BLA_PATH&quot; # a:b:c:d (quoted)
+echo "$BLA_PATH" # a:b:c:d (quoted)
env | grep BLA_PATH # BLA_PATH=a:b:c:d (env)
set FOO_PATH x y z
echo $FOO_PATH # x y z
-echo &quot;$FOO_PATH&quot; # x:y:z
+echo "$FOO_PATH" # x:y:z
</code></pre>
<h2 id="command-handling"><a class="header" href="#command-handling">Command Handling</a></h2>
<pre><code class="language-sh"># sub-commands are not run in quotes
-echo &quot;ls output: &quot;(ls)
+echo "ls output: "(ls)
</code></pre>
<h3 id="io-redirection"><a class="header" href="#io-redirection">I/O redirection</a></h3>
<pre><code class="language-sh"># 'noclobber', fail if 'log' already exists
@@ -315,7 +315,7 @@ funced foo # edit function 'foo'
<li><a href="https://fishshell.com/docs/current/completions.html">Writing your own completions</a></li>
<li><a href="https://fishshell.com/docs/current/cmds/complete.html"><code>complete</code></a></li>
</ul>
-<pre><code class="language-sh">function moose --d &quot;my moose fn&quot;
+<pre><code class="language-sh">function moose --d "my moose fn"
# h/help : short / long option (boolean)
# color : only long option (boolean)
# u/user= : option with required argument, only last specified is taken
@@ -325,18 +325,18 @@ funced foo # edit function 'foo'
or return
if set -ql _flag_help
- echo &quot;usage ...&quot;
+ echo "usage ..."
return 0
end
set -ql _flag_file
- and echo &quot;file=$_flag_file | cnt:&quot; (count $_flag_file)
+ and echo "file=$_flag_file | cnt:" (count $_flag_file)
set -ql _flag_color
- and echo &quot;color=$_flag_color&quot;
+ and echo "color=$_flag_color"
set -ql _flag_user
- and echo &quot;user=$_flag_user&quot;
+ and echo "user=$_flag_user"
end
# Delete all previous defined completions for 'moose'.
@@ -348,31 +348,31 @@ complete -c moose --no-files
# Help completion.
# -n specifies a conditions. The completion is only active if the command
# returns 0.
-complete -c moose -s h -l help -n &quot;not __fish_contains_opt -s h help&quot; \
- --description &quot;Print usage help and exit&quot;
+complete -c moose -s h -l help -n "not __fish_contains_opt -s h help" \
+ --description "Print usage help and exit"
# File completion.
# -F force complete files (overwrite --no-files).
# -r requires argument.
complete -c moose -s f -l file -F -r \
- --description &quot;Specify file (can be passed multiple times)&quot;
+ --description "Specify file (can be passed multiple times)"
# Color completion.
# -a options for completion.
# -x short for -r and --no-files (-f)
-complete -c moose -x -l color -a &quot;red blue&quot; \
- --description &quot;Specify a color.&quot;
+complete -c moose -x -l color -a "red blue" \
+ --description "Specify a color."
# User completion.
# -a options for completion. Call a function to generate arguments.
-complete -c moose -x -s u -l user -a &quot;(__fish_complete_users)&quot; \
- --description &quot;Specify a user&quot;
+complete -c moose -x -s u -l user -a "(__fish_complete_users)" \
+ --description "Specify a user"
</code></pre>
<h2 id="prompt"><a class="header" href="#prompt">Prompt</a></h2>
<p>The prompt is defined by the output of the <code>fish_prompt</code> function.</p>
<pre><code class="language-sh">function fish_prompt
set -l cmd_ret
- echo &quot;&gt; &quot;(pwd) $cmd_ret&quot; &quot;
+ echo "&gt; "(pwd) $cmd_ret" "
end
</code></pre>
<blockquote>
@@ -397,7 +397,7 @@ string split SEP STRING
# math
math -b hex 4096 # output dec as hex
math 0x1000 # output hex as dec
-math &quot;log2(1024)&quot; # call functions
+math "log2(1024)" # call functions
math -s0 7/3 # integer division (by default float)
# status
diff --git a/tools/gdb.html b/tools/gdb.html
index 4a0dcea..44846a6 100644
--- a/tools/gdb.html
+++ b/tools/gdb.html
@@ -356,7 +356,7 @@ thread name &lt;name&gt;
</code></pre>
<h2 id="configuration"><a class="header" href="#configuration">Configuration</a></h2>
<pre><code class="language-markdown"> set disassembly-flavor &lt;intel | att&gt;
- Set the disassembly style &quot;flavor&quot;.
+ Set the disassembly style "flavor".
set pagination &lt;on | off&gt;
Turn on/off gdb's pagination.
diff --git a/tools/git.html b/tools/git.html
index fe62b83..2d64c24 100644
--- a/tools/git.html
+++ b/tools/git.html
@@ -247,7 +247,7 @@
branch has additional commits compared to remote branch).
</code></pre>
<h2 id="tags"><a class="header" href="#tags">Tags</a></h2>
-<pre><code class="language-markdown"> git tag -a &lt;tname&gt; -m &quot;descr&quot; ........ creates an annotated tag (full object
+<pre><code class="language-markdown"> git tag -a &lt;tname&gt; -m "descr" ........ creates an annotated tag (full object
containing tagger, date, ...)
git tag -l ........................... list available tags
git checkout tag/&lt;tname&gt; ............. checkout specific tag
diff --git a/tools/gnuplot.html b/tools/gnuplot.html
index a794455..85ec9bd 100644
--- a/tools/gnuplot.html
+++ b/tools/gnuplot.html
@@ -185,30 +185,30 @@ gnuplot [opt]
opt:
-p ................ persist plot window
-c &lt;file&gt; ......... run script file
- -e &quot;&lt;cmd1&gt;; ..&quot; ... run cmd(s)
+ -e "&lt;cmd1&gt;; .." ... run cmd(s)
</code></pre>
<h2 id="frequently-used-configuration"><a class="header" href="#frequently-used-configuration">Frequently used configuration</a></h2>
<pre><code class="language-sh"># Plot title.
-set title &quot;the plot&quot;
+set title "the plot"
# Labels.
-set xlabel &quot;abc&quot;
-set ylabel &quot;def&quot;
+set xlabel "abc"
+set ylabel "def"
# Output format, 'help set term' for all output formats.
set term svg
# Output file.
-set output &quot;out.svg&quot;
+set output "out.svg"
# Make axis logarithmic to given base.
set logscale x 2
# Change separator, default is whitespace.
-set datafile separator &quot;,&quot;
+set datafile separator ","
</code></pre>
<h2 id="plot"><a class="header" href="#plot">Plot</a></h2>
<pre><code class="language-sh"># With specific style (eg lines, linespoint, boxes, steps, impulses, ..).
-plot &quot;&lt;data_file&gt;&quot; with &lt;plot_style&gt;
+plot "&lt;data_file&gt;" with &lt;plot_style&gt;
&gt; cat data.txt
1 1 3
@@ -217,30 +217,30 @@ plot &quot;&lt;data_file&gt;&quot; with &lt;plot_style&gt;
4 2 2
# Plot specific column.
-plot &quot;data.txt&quot; using 1:2, &quot;data.txt&quot; using 1:3
-# Equivalent using the special file &quot;&quot;, which re-uses the previous input file.
-plot &quot;data.txt&quot; using 1:2, &quot;&quot; using 1:3
+plot "data.txt" using 1:2, "data.txt" using 1:3
+# Equivalent using the special file "", which re-uses the previous input file.
+plot "data.txt" using 1:2, "" using 1:3
# Plot piped data.
-plot &quot;&lt; head -n2 data.txt&quot;
+plot "&lt; head -n2 data.txt"
# Plot with alternate title.
-plot &quot;data.txt&quot; title &quot;moose&quot;
+plot "data.txt" title "moose"
</code></pre>
<h2 id="example-multiple-data-sets-in-on-plot"><a class="header" href="#example-multiple-data-sets-in-on-plot">Example: multiple data sets in on plot</a></h2>
<pre><code class="language-sh"># file: mem_lat.plot
-set title &quot;memory latency (different strides)&quot;
-set xlabel &quot;array in KB&quot;
-set ylabel &quot;cycles / access&quot;
+set title "memory latency (different strides)"
+set xlabel "array in KB"
+set ylabel "cycles / access"
set logscale x 2
-plot &quot;stride_32.txt&quot; title &quot;32&quot; with linespoints, \
- &quot;stride_64.txt&quot; title &quot;64&quot; with linespoints, \
- &quot;stride_128.txt&quot; title &quot;128&quot; with linespoints, \
- &quot;stride_256.txt&quot; title &quot;256&quot; with linespoints, \
- &quot;stride_512.txt&quot; title &quot;512&quot; with linespoints
+plot "stride_32.txt" title "32" with linespoints, \
+ "stride_64.txt" title "64" with linespoints, \
+ "stride_128.txt" title "128" with linespoints, \
+ "stride_256.txt" title "256" with linespoints, \
+ "stride_512.txt" title "512" with linespoints
</code></pre>
<p>On Linux x86_64, <a href="gnuplot/mem_lat.c"><code>mem_lat.c</code></a> provides an example which can
be run as follows.</p>
diff --git a/tools/pacman.html b/tools/pacman.html
index e36c851..72f0052 100644
--- a/tools/pacman.html
+++ b/tools/pacman.html
@@ -212,7 +212,7 @@ dependencies.</p>
package and sort by size.</p>
<pre><code class="language-text">pacman -Qetq | xargs pacman -Qi |
awk '/Name/ { name=$3 }
- /Installed Size/ { printf &quot;%8.2f%s %s\n&quot;, $4, $5, name }' |
+ /Installed Size/ { printf "%8.2f%s %s\n", $4, $5, name }' |
sort -h
</code></pre>
<p>Install package into different <code>root</code> directory but keep using the default
diff --git a/tools/qemu.html b/tools/qemu.html
index 25cf9b3..650ae67 100644
--- a/tools/qemu.html
+++ b/tools/qemu.html
@@ -365,10 +365,10 @@ qemu-system-x86_64 -monitor stdio -incoming tcp:0.0.0.0:12345
qemu-system-x86_64 -monitor stdio -cdrom &lt;iso&gt;
# Save VM state to file.
-(qemu) migrate &quot;exec:gzip -c &gt; vm.gz&quot;
+(qemu) migrate "exec:gzip -c &gt; vm.gz"
# Load VM from file.
-qemu-system-x86_64 -monitor stdio -incoming &quot;exec: gzip -d -c vm.gz&quot;
+qemu-system-x86_64 -monitor stdio -incoming "exec: gzip -d -c vm.gz"
</code></pre>
<blockquote>
<p>The migration source machine and the migration target machine should be
@@ -380,7 +380,7 @@ launched with the <strong>same</strong> parameters.</p>
-cpu host \
-enable-kvm \
-kernel &lt;dir&gt;/arch/x86/boot/bzImage \
- -append &quot;earlyprintk=ttyS0 console=ttyS0 nokaslr init=/init debug&quot; \
+ -append "earlyprintk=ttyS0 console=ttyS0 nokaslr init=/init debug" \
-initrd &lt;dir&gt;/initramfs.cpio.gz \
...
</code></pre>
@@ -396,7 +396,7 @@ trace: test
clean:
$(RM) test test-bin test.o
</code></pre>
-<pre><code class="language-x86asm">.section .text, &quot;ax&quot;
+<pre><code class="language-x86asm">.section .text, "ax"
.global _start
_start:
diff --git a/tools/radare2.html b/tools/radare2.html
index dd868f0..199a747 100644
--- a/tools/radare2.html
+++ b/tools/radare2.html
@@ -208,7 +208,7 @@
&gt; rasm2 -a x86 'mov eax, 0xdeadbeef'
b8efbeadde
- &gt; rasm2 -a x86 -d &quot;b8efbeadde&quot;
+ &gt; rasm2 -a x86 -d "b8efbeadde"
mov eax, 0xdeadbeef
</code></pre>
diff --git a/tools/sed.html b/tools/sed.html
index 5796ea9..f44fb19 100644
--- a/tools/sed.html
+++ b/tools/sed.html
@@ -182,6 +182,8 @@
-i edit file in place
-i.bk edit file in place and create backup file
(with .bk suffix, can be specified differently)
+ --follow-symlinks
+ follow symlinks when editing in place
-e SCRIPT add SCRIPT to commands to be executed
(can be specified multiple times)
-f FILE add content of FILE to command to be executed
@@ -232,6 +234,12 @@ echo -e 'aa\nbb' | sed '2aABC'
echo -e 'aa\nbb' | sed '2cABC'
# aa
# ABC
+
+# Insert before pattern match.
+echo -e 'aa\nbb' | sed '/bb/i 123'
+# aa
+# 123
+# bb
</code></pre>
<h3 id="substitute-lines"><a class="header" href="#substitute-lines">Substitute lines</a></h3>
<pre><code class="language-sh"># Substitute by regex.
@@ -244,6 +252,20 @@ echo -e 'aafooaa\ncc' | sed 's/foo/MOOSE/'
# BAR
# bar
</code></pre>
+<h3 id="edit-inplace-through-symlink"><a class="header" href="#edit-inplace-through-symlink">Edit inplace through symlink</a></h3>
+<pre><code class="language-sh">touch file
+ln -s file link
+ls -l link
+# lrwxrwxrwx 1 johannst johannst 4 Feb 7 23:02 link -&gt; file
+
+sed -i --follow-symlinks '1iabc' link
+ls -l link
+# lrwxrwxrwx 1 johannst johannst 4 Feb 7 23:02 link -&gt; file
+
+sed -i '1iabc' link
+ls -l link
+# -rw-r--r-- 1 johannst johannst 0 Feb 7 23:02 link
+</code></pre>
</main>
diff --git a/tools/tmux.html b/tools/tmux.html
index f5847cb..3512eeb 100644
--- a/tools/tmux.html
+++ b/tools/tmux.html
@@ -215,7 +215,7 @@ tmux list-panes -F '#P' -t &lt;s&gt;:&lt;w&gt; list pane IDs for window &lt;w&
tmux selectp -t &lt;s&gt;:&lt;w&gt;.&lt;p&gt; select pane &lt;p&gt; in window &lt;w&gt; in session &lt;s&gt;
# Run commands
-tmux send -t &lt;s&gt;:&lt;w&gt;.&lt;p&gt; &quot;ls&quot; C-m send cmds/keys to pane
+tmux send -t &lt;s&gt;:&lt;w&gt;.&lt;p&gt; "ls" C-m send cmds/keys to pane
tmux run -t &lt;p&gt; &lt;sh-cmd&gt; run shell command &lt;sh-cmd&gt; in background and report output on pane -t &lt;p&gt;
</code></pre>
<p>For example cycle through all panes in all windows in all sessions:</p>
diff --git a/tools/zsh.html b/tools/zsh.html
index acdc32f..e6ec715 100644
--- a/tools/zsh.html
+++ b/tools/zsh.html
@@ -198,11 +198,11 @@ $RBUFFER # Edit buffer content right to cursor
# create zle widget which adds text right of the cursor
function add-text() {
- RBUFFER=&quot;some text $RBUFFER&quot;
+ RBUFFER="some text $RBUFFER"
}
zle -N add-text
-bindkey &quot;^p&quot; add-text
+bindkey "^p" add-text
</code></pre>
<h2 id="parameter"><a class="header" href="#parameter">Parameter</a></h2>
<p>Default value:</p>
@@ -336,10 +336,10 @@ option should be stored.</li>
<pre><code class="language-zsh">#!/bin/zsh
function test() {
zparseopts -D -E -A opts f=flag o: -long:
- echo &quot;flag $flag&quot;
- echo &quot;o $opts[-o]&quot;
- echo &quot;long $opts[--long]&quot;
- echo &quot;pos $1&quot;
+ echo "flag $flag"
+ echo "o $opts[-o]"
+ echo "long $opts[--long]"
+ echo "pos $1"
}
test -f -o OPTION --long LONG_OPT POSITIONAL
@@ -361,9 +361,9 @@ The match results can be accessed via the <code>$MATCH</code> variable and
<pre><code class="language-zsh">INPUT='title foo : 1234'
REGEX='^title (.+) : ([0-9]+)$'
if [[ $INPUT =~ $REGEX ]]; then
- echo &quot;$MATCH&quot; # title foo : 1234
- echo &quot;$match[1]&quot; # foo
- echo &quot;$match[2]&quot; # 1234
+ echo "$MATCH" # title foo : 1234
+ echo "$match[1]" # foo
+ echo "$match[2]" # 1234
fi
</code></pre>
<h2 id="completion"><a class="header" href="#completion">Completion</a></h2>
@@ -395,7 +395,7 @@ $words[CURRENT-1] # previous word (relative to cursor position)
</code></pre>
<ul>
<li><code>MSG</code> simple string with header message</li>
-<li><code>COMP</code> array of completions where each entry is <code>&quot;opt:description&quot;</code></li>
+<li><code>COMP</code> array of completions where each entry is <code>"opt:description"</code></li>
</ul>
<pre><code class="language-zsh">function _foo() {
local -a opts
@@ -436,16 +436,16 @@ function _foo_color() {
colors+=('green:green color')
colors+=('red:red color')
colors+=('blue:blue color')
- _describe &quot;color&quot; colors
+ _describe "color" colors
}
function _foo() {
_arguments \
- &quot;-c[define color]:color:-&gt;s_color&quot; \
- &quot;-s[select sound]:sound:(low high)&quot; \
- &quot;-f[select file]:file:_files&quot; \
- &quot;-d[select dir]:dir:_files -/&quot; \
- &quot;-h[help]&quot;
+ "-c[define color]:color:-&gt;s_color" \
+ "-s[select sound]:sound:(low high)" \
+ "-f[select file]:file:_files" \
+ "-d[select dir]:dir:_files -/" \
+ "-h[help]"
case $state in
s_color) _foo_color;;
@@ -459,9 +459,9 @@ arguments such as</p>
</code></pre>
<pre><code class="language-zsh">function _foo() {
_arguments \
- &quot;1:opt 1:(a b c)&quot; \
- &quot;:opt next:(d e f)&quot; \
- &quot;*:opt all:(u v w)&quot;
+ "1:opt 1:(a b c)" \
+ ":opt next:(d e f)" \
+ "*:opt all:(u v w)"
}
</code></pre>
<p>Explanation:</p>