New answers tagged

0

If you're on an apline linux container and don't want/can't pull down these other tools, this might work in a pinch. RED="\\\033[0;31m" GREEN="\\\033[0;32m" OFF="\\\033[0m" DIFF=$(diff --label "GOT" <(echo "$OUTPUT") --label "EXPECTED" <(echo "$EXPECTED_OUTPUT")) printf -- "$(echo "$DIFF" | sed "s|^-|$RED-|g" | sed "s|^+|$GREEN+|g" | sed "s|$|$OFF|g")"...


2

What I know is that I need to end -exec with {} \; but why there's backslash inside the curly braces? The backslashes remove the special meaning of the following character, like here: $ echo $SHELL /bin/bash $ echo \$SHELL $SHELL That's what they do here, too, except that in sh-like shells {} isn't special to begin with, so they're not needed. They would ...


0

The {} get substituted by the entities found by find. At least in bash the escaping of the {} is not nessesary so a ...-exec ls -l --full-time {} \; might work as well.


0

print_underlined() { [ "$#" -eq 0 ] || printf '%s\n' "$@" | sed 'p;s/./-/g' } would print its arguments each on separate lines and each line underlined. print_underlined foo bar 'foo and bar' prints: foo --- bar --- foo --- and bar ------- Note that it assumes all characters are single-width. Lines that contain zero-width, double-width or cursor ...


0

For some reason the accepted answer did not print the correct amount of characters with some strings. However, this worked for me: printf %${#word}s |tr " " "=" And in one line echo -e "$word\n"$(printf %${#word}s |tr " " "=")


1

Install Generic Colouriser (grc) and: grc diff file1 file2 Available on both Linux and MacOS.


2

It's sometimes easier to send all the headers in the echo e.g. { echo From: xxxx echo To: yyyy echo Subject: Foobar echo echo This is the message } | /usr/lib/sendmail -t


1

Subject is part of the headers, try: echo -e "Subject:$SUBJECT" | /usr/sbin/sendmail -f XXXXXX@gmail.com -t XXXXXX@gmail.com


0

A shell function that is available at the shell prompt is not automatically available to a script called from that shell. There are two high level ways to get access. Source the script that sets up the function. Before you do this you would want to have a really good idea of what else this script is doing; without some local knowledge I can't recommend ...


Top 50 recent answers are included