<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Regel on Notities</title><link>https://d8224bcf.backup-website.pages.dev/tags/regel/</link><description>Recent content in Regel on Notities</description><generator>Hugo</generator><language>nl</language><lastBuildDate>Mon, 20 Jul 2026 22:38:58 +0200</lastBuildDate><atom:link href="https://d8224bcf.backup-website.pages.dev/tags/regel/index.xml" rel="self" type="application/rss+xml"/><item><title>Bash script met een SUCCES of FAILED melding aan het einde van de regel</title><link>https://d8224bcf.backup-website.pages.dev/blog/2024-bash-script-met-een-succes-of-failed-melding-aan-het-einde-van-de-regel/</link><pubDate>Wed, 31 Jan 2024 20:18:39 +0000</pubDate><guid>https://d8224bcf.backup-website.pages.dev/blog/2024-bash-script-met-een-succes-of-failed-melding-aan-het-einde-van-de-regel/</guid><description>&lt;p&gt;Z﻿ie hieronder een voorbeeld script om aan het einde van de regel helemaal rechts uitgelijnd een SUCCES melding in het groen of een FAILED melding in het rood te krijgen.&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;#!/bin/bash

# Set the message
success_message=&amp;#34;Your command was successful&amp;#34;
failed_message=&amp;#34;Your command failed&amp;#34;

# Set the &amp;#34;OK&amp;#34; string in green
ok=&amp;#34;$(tput setaf 2)[SUCCES]$(tput sgr0)&amp;#34;
failed=&amp;#34;$(tput setaf 1)[FAILED]$(tput sgr0)&amp;#34;

# Get the width of the terminal
term_width=$(tput cols)+9

# Calculate the number of dots needed
success_dots_count=$((term_width - ${#success_message} - ${#ok}))
failed_dots_count=$((term_width - ${#failed_message} - ${#failed}))

# Create a string of dots for success and failed messages
success_dots=$(printf &amp;#34;%0.s.&amp;#34; $(seq 1 $success_dots_count))
failed_dots=$(printf &amp;#34;%0.s.&amp;#34; $(seq 1 $failed_dots_count))

# Print the success message with dots and &amp;#34;OK&amp;#34; at the end of the line
printf &amp;#34;%s%s%s\n&amp;#34; &amp;#34;$success_message &amp;#34; &amp;#34;$success_dots&amp;#34; &amp;#34; $ok&amp;#34;

# Print the failed message with dots and &amp;#34;FAILED&amp;#34; at the end of the line
printf &amp;#34;%s%s%s\n&amp;#34; &amp;#34;$failed_message &amp;#34; &amp;#34;$failed_dots&amp;#34; &amp;#34; $failed&amp;#34;
&lt;/code&gt;&lt;/pre&gt;</description></item></channel></rss>