• Korn Shell / Bash,  PowerShell,  Shell Scripting,  Windows Bash

    đź’ˇHow to Extract Specific Lines from a File: sed, awk, head/tail, grep, and with powershell

    In the command line, it’s often necessary to extract only specific lines from a text file – whether it’s a single line or a range of lines. Fortunately, Bash offers several powerful tools for this. In this blog post, I’ll show you the most common methods using sed, awk, head/tail, and grep. Additionally, I will demonstrate an option when using PowerShell. Extracting Lines with sed sed (Stream EDitor) is a classic for text manipulation in the shell and is excellent for selectively outputting line ranges.Output a Single Line (e.g., Line 102)To output a specific line, such as line 102, you use the p command (print) in combination with the -n…

  • PowerShell,  Shell Scripting,  Uncategorized

    đź’ˇPowershell Tip – Search directories and subdirectories for files with specific content

    I’d like to share a small PowerShell script that scans all subdirectories for specific files (for example, *.yaml and *.yml) and searches them for a specific string (e.g., “ansible.builtin.template”). The result is returned with the location (name and path of the file, and line number of the search string in the file). What it does: Sometimes I want to save my results to a file and explore them further. To save the results to a CSV file, adapt the script as follows:

  • ansible

    Get systemd services in ansible plays

    Hi, this is a tip to get details about linux (e.g. systemd) services in an ansible play. Just use the ansible service_facts module. You can use it without passing any argument. You can access services by using ansible_facts.services. As this is an dictionary, a single service is addressable by using ansible_facts.services[{{ service-name }}]. A few more examples:

  • ansible,  DevOps

    use ansible module copy instead of template for small files

    In order to adapt files and their content on target servers I am used to using ansible copy module. However, if you only have a small file with just one or a few lines, you can do so without creating a jinja2 template. Here is the little cheat: Just use ansible’s copy module. That’s it. This creates a file with variable content, without need to create a template.

  • Branching & Merging,  Git

    merge particular files in another branch

    Every now and then I am faced with the question of how I can transfer individual files from a feature branch. git cherry-pick is intended for taking over the contents of a commit. But if I only want to take over individual files, this tool is probably not the solution. In order not to make it too exciting, here is the simple answer: I want to explain it using a specific example. In the feature branch I have the files iWwantThat.yml and alsoNeeded2.py. To transfer these two files and only these to the main branch, I switch to the main branch and run the git checkout:

  • Apache HTTPD,  DevOps,  Ubuntu

    HTTPS Setup fĂĽr eine Flask Anwendung – Teil 2

    Im ersten Teil habe ich die Einrichtung des Ubuntu Servers fĂĽr meine kleine Webanwendung fĂĽr den isländisch Kurs beschrieben. Im zweiten Teil möchte ich kurz auf die HTTPS Einrichtung eingehen. Die DigitalOcean Anleitung fĂĽr Ubuntu 18.04 funktioniert nicht unter Ubunt 20.x. Bitte darauf achren, die Anleitung fĂĽr das eingesetzte Ubuntu Release (hier 20.04) zu verwenden, falls vorhanden. Das verwendete Repository ppa:certbot/certbot ist im Status DEPRECATED. Daher wird der Certbot fĂĽr die Let’s Encrypt Zertifikate Ein Apache Virtual Host ist Vorausssetzung fĂĽr die nächsten Schritte. Die Einrichtung habe ich in Teil 1 beschrieben. HTTPS Zugriff durch die Firewall Der aktuelle Status der Firewall wird mit ufw abgefragt: Um eingehende HTTPS Anfragen…

  • DevOps,  Flask,  Github,  Github Actions,  Python,  YAML

    Web Anwendung basierend auf Python Flask – Teil 3

    Der dritte Teil beschreibt die Webanwendung meines Isländisch Trainers. Ich habe den Quellcode auf Gihub veröffentlicht. Der hauptteil der Anwendung besteht aus 2 Webseiten. Die erste eröffnet eine Session und zeigt ein Wort aus einer Liste an. Die Wörterliste ist im yaml Format erstellt. Die Struktur entspricht einen Dictionary: Ein Zufallsgenerator suche ein Wort aus dieser Liste und zeigt die deutsche Ăśbersetzung an. Der Lernwillige kann sich die Deklinaktion der Fälle in Singular und Plural, mit und ohne Artikel ansehen. Ob seine Kenntnisse richtig sind, zeigt Seite 2 nach Absenden des Formulars in Form eines simplen Buttons an. Die Lösungsseite zeigt die korrekten Deklinationen an und eine Link auf die…

  • Apache HTTPD,  DevOps,  Github,  Ubuntu

    Digitalocean Setup fĂĽr eine Flask Anwendung – Teil 1

    Dieser Blog wird Teil einer Serie fĂĽr eine Web Anwendung in Python auf einer Cloud Instanz. Ich habe mich fĂĽr DigialOcean entschieden. Linode, Azure, GCP, … wären alle genau so gut fĂĽr diesen Zweck. Die Anwendung wird aus einer Liste von Vokabeln ein Wort in Deutsch heraussuchen und anzeigen. Auf einer zweiten Seite wird die Ăśbersetzung des Worts und die Deklination angezeigt. Im ersten Teil werde ich die Einrichtung des Servers beschreiben. Teil 2 wird die HTTPS Konfiguration behandeln. Teil 3 schliesslich beschreibt die Python Flask Anwendung und deren Deployment mit Github Actions. Teil 4 wird die Einrichtung der Subdomain is.hslomka.de und die Umleitung auf meinen Server beinhalten. Das Ergebnis…