I know there are many ways the same thing can be done in the shell but there are so many problems here. Please take this as feedback and not harsh criticism (I know there's comment section on the blog but I'd rather not give my e-mail to yet another website).<p><pre><code> > cat /etc/passwd | sed 's/\([^:]*\):.*:\(.*\)/user: \1 shell: \2/'
</code></pre>
Besides the needless cat this is clearer in awk, a tool you mention just prior.<p><pre><code> awk '{FS=":"} {print "user: " $1, "shell: " $NF}' /etc/passwd
> $ ls | xargs -t ls -l
</code></pre>
Beware files with whitespace in their names.<p><pre><code> > find . | grep azurerm | grep tf$ | xargs -n1 dirname | sed 's/^.\///'
>
> ...
>
> for each of those files, removes the leading dot and forward slash, leaving the final bare filename (eg somefile.tf)
</code></pre>
No it doesn't it returns the names of parent directories where files ending in "tf" are found and where the path also includes the string "azurerm".<p><pre><code> > $ ls | grep Aug | xargs -IXXX mv XXX aug_folder
</code></pre>
Ew.<p><pre><code> mv *Aug* aug_folder/
</code></pre>
Though now the issue of whitespace in path names is mentioned. Another minior point here is that with GNU xargs at least when using -I -L 1 is implied, so the original example is equivalent to a loop.<p><pre><code> > $ ps -ef | grep VBoxHeadless | awk '{print $2}' | xargs kill -9
pkill VBoxHeadless
</code></pre>
You acknowledge to avoid SIGKILL if possible so I don't know why you put it in the example.<p><pre><code> > $ sudo updatedb
> $ sudo locate cfg | grep \.cfg$
locate '*.cfg'
</code></pre>
No idea why sudo is used when running locate, also it takes a glob so the grep here can be avoided.<p><pre><code> > $ grep ^.https doc.md | sed 's/^.(h[^])]).*/open \1/' | sh
</code></pre>
Now this is just nutty.<p><pre><code> > This example looks for https links at the start of lines in the doc.md file
</code></pre>
No it doesn't, it matches the start of the line, followed by a character, then "https".<p>The sed then matches start of the line, followed by a character, starts a capture group of the letter "h" followed by a single character that is not "]" or ")", closes the capture group and continues to match anything.<p>The example given will always result in "open ht" for any hit.<p>Then there's the piping to sh. You mention like to drop this to review the list. I'd suggest focusing on extracting the list of links then pipe to xargs open. If you get a pipeline wrong you could unintentionally blast something into a shell executing anything which might be very bad.<p><pre><code> > Give Me All The Output With 2>&1
&> stdout-and-stderr
</code></pre>
But each to their own.<p><pre><code> > env | grep -w PATH | tr ':' '\n'
echo $PATH | tr ':' '\n'
</code></pre>
or<p><pre><code> tr ':' '\n' <<< $PATH
</code></pre>
Edit: I know the formatting of this comment is terrible, I think quoting the sed example caused the rest of the comment to be marked up as italics so I indented it along with the other quotes as code.